This brain-friendly guide teaches you everything from JavaScript language fundamentals to advanced topics, including objects, functions, and the browser’s document object model. You won’t just be reading—you’ll be playing games, solving puzzles, pondering mysteries, and interacting with JavaScript in ways you never imagined. And you’ll write real code, lots of it, so you can start building your own web applications.
Writing the prinAndGetHighScore function.
We’ve got the code for the printAndGetHighScore function already. It’s just the code we’ve already written, but to make it a function we need to think through what arguments we’re passing it, and if it returns anything back to us.
Now, passing in the scores array seems like a good idea because that way, we can reuse the function on other arrays with bubble scores. And we want to return the high score that we compute in the function, so the code that calls the function can do interesting things with it (and, after all, we’re going to need it to figure out the best solutions).
Oh, and another thing: often you want your functions to do one thing well. Here we’re doing two things: we’re displaying all the scores in the array and we’re also computing the high score. We might want to consider breaking this into two functions, but given how simple things are right now we’re going to resist the temptation. If we were working in a professional environment we might reconsider and break this into two functions, printScores and getHighScore. But for now, we’ll stick with one function. Let’s get this code refactored:
Contents.
Table of Contents (Summary).
1 A quick dip into JavaScript: Getting your feet wet.
2 Writing real code: Going further.
3 Introducing functions: Getting functional.
4 Putting some order in your data: Arrays.
5 Understanding objects: A trip to Objectville.
6 Interacting with your web page: Getting to know the DOM.
7 Types, equality, conversion, and all that jazz: Serious types.
8 Bringing it all together: Building an app.
9 Asynchronous coding: Handling events.
10 First-class functions: Liberated functions.
11 Anonymous functions, scope, and closures: Serious functions.
12 Advanced object construction: Creating objects.
13 Using prototypes: Extra-strength objects.
Appendix: The Top Ten Topics (we didn’t cover): Leftovers.
Table of Contents (the real thing).
Who is this book for?.
We know what you’re thinking.
We think of a “Head First” reader as a learner.
Metacognition: thinking about thinking.
Here’s what WE did.
Here’s what YOU can do to bend your brain into submission.
Read Me.
Tech Reviewers.
Acknowledgments.
Бесплатно скачать электронную книгу в удобном формате, смотреть и читать:
Скачать книгу Head First JavaScript Programming, Freeman E., Robson E., 2014 - fileskachat.com, быстрое и бесплатное скачивание.
Скачать pdf
Ниже можно купить эту книгу по лучшей цене со скидкой с доставкой по всей России.Купить эту книгу
Скачать - pdf - Яндекс.Диск.
Дата публикации:
Хештеги: #учебник по программированию :: #программирование :: #Freeman :: #Robson
Смотрите также учебники, книги и учебные материалы:
Следующие учебники и книги:
- JavaScript for Kids, Morgan N., 2014
- Introducing Python, Modern Computing in Simple Packages, Second edition, Lubanovic B., 2020
- Introducing Python, Modern Computing in Simple Packages, Lubanovic B., 2015
- Head First Python, Barry P., 2017
Предыдущие статьи:
- Head First C#, Stellman A., Greene J., 2013
- Технология программирования на C++, Win32 API-приложения, Литвиненко Н.А., 2010
- Coding with JavaScript For Dummies, Minnick C., Holland E., 2015
- C# для чайников, Мюллер Д.И., Семпф Б., Сфер Ч., 2019