Get Begin to Code with JavaScript 1st Edition Miles PDF ebook with Full Chapters Now
Get Begin to Code with JavaScript 1st Edition Miles PDF ebook with Full Chapters Now
com
https://textbookfull.com/product/begin-to-code-with-
javascript-1st-edition-miles/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/begin-to-code-with-python-rob-miles/
textboxfull.com
https://textbookfull.com/product/source-code-analytics-with-roslyn-
and-javascript-data-visualization-mukherjee/
textboxfull.com
https://textbookfull.com/product/reactive-programming-with-
rxjs-5-untangle-your-asynchronous-javascript-code-1st-edition-sergi-
mansilla/
textboxfull.com
https://textbookfull.com/product/refactoring-javascript-turning-bad-
code-into-good-code-first-edition-burchard/
textboxfull.com
MASTERING JAVASCRIPT DESIGN PATTERNS create scalable and
reliable applications with advanced Javascript design
patterns using reliable code 3rd Edition Tomas Corral
Cosas
https://textbookfull.com/product/mastering-javascript-design-patterns-
create-scalable-and-reliable-applications-with-advanced-javascript-
design-patterns-using-reliable-code-3rd-edition-tomas-corral-cosas/
textboxfull.com
https://textbookfull.com/product/models-to-code-with-no-mysterious-
gaps-1st-edition-leon-starr/
textboxfull.com
https://textbookfull.com/product/simplifying-javascript-writing-
modern-javascript-with-es5-es6-and-beyond-1st-edition-joe-morgan/
textboxfull.com
Rob Miles
BEGIN TO CODE WITH JAVASCRIPT
No patent liability is assumed with respect to the use of the information contained
herein. Although every precaution has been taken in the preparation of this book,
the publisher and author assume no responsibility for errors or omissions. Nor is
any liability assumed for damages resulting from the use of the information
contained herein.
ISBN-13: 978-0-13-687072-2
ISBN-10: 0-13-687072-4
ScoutAutomatedPrintCode
TRADEMARKS
Every effort has been made to make this book as complete and as accurate as
possible, but no warranty or fitness is implied. The information provided is on an
“as is” basis. The author, the publisher, and Microsoft Corporation shall have
neither liability nor responsibility to any person or entity with respect to any loss
or damages arising from the information contained in this book or from the use
of the programs accompanying it.
SPECIAL SALES
For information about buying this title in bulk quantities, or for special sales
opportunities (which may include electronic versions; custom cover designs; and
content particular to your business, training goals, marketing focus, or branding
interests), please contact our corporate sales department at
[email protected] or (800) 382-3419.
Editor-in-Chief
Brett Bartow
Executive Editor
Loretta Yates
Development Editor
Rick Kughen
Sponsoring Editor
Charvi Arora
Managing Editor
Sandra Schroeder
Tracey Croom
Copy Editor
Rick Kughen
Indexer
James Minken
Proofreader
Scout Festa
Technical Editor
John E. Ray
Editorial Assistant
Cindy Teeters
Cover Designer
Compositor
Danielle Foster
Graphics
Danielle Foster
To Imogen
About the author
Chapter 9 Objects
Introduction
1 Running JavaScript
What is JavaScript?
JavaScript origins
Tools
Getting Git
What is HTML?
Display symbols
Create headings
Using a button
Egg timer
Text alignment
Cascading styles
Variables in programs
JavaScript identifiers
Performing calculations
Making applications
Adding comments
Global variables
Boolean thinking
Boolean expressions
Logical operators
The if construction
App development
7 Creating functions
Arrays of arguments
8 Storing data
Collections of data
Creating an array
9 Objects
Prototype HTML
Prototype JavaScript
Storing contact details
Finding contacts
Displaying contacts
Saving a contact
Finding a contact
Catching exceptions
Class design
Object-oriented design
Data storage
11 Creating applications
Data analysis
Node.js
12 Creating games
Canvas coordinates
Computer art
Animate images
Control gameplay
Window events
Control object position with a keyboard
Game sprites
Add sound
Adding scores
Programming is the most creative thing you can learn how to do. Why? If
you learn to paint, you can create pictures. If you learn to play the violin,
you can make music, but if you learn to program, you can create entirely
new experiences (and you can make pictures and music, too, if you want).
Once you’ve started on the programming path, there’s no limit to where
you can go. There are always new devices, technologies, and
marketplaces where you can use your programming skills.
But first, a word of warning: I would not say that learning to write
programs is easy. This is for two reasons:
If I tell you that it’s easy, and you still can’t do it, you might feel bad about
this (and rather cross with me).
If I tell you it’s easy and you manage to do it, you might think that it isn’t
worth doing.
Learning to program is not easy. It’s a kind of difficult that you might not
have seen before. Programming is all about detail and sequencing. You
must learn how the computer does things and how to express what you
want it to do.
Imagine that you were lucky enough to be able to afford your own
personal chef. At the start, you would have to explain things like, “If it is
sunny outside, I like orange juice and a grapefruit for breakfast, but if it is
raining, I’d like a bowl of porridge and a big mug of coffee.” Occasionally,
your chef would make mistakes. Perhaps you would get a black coffee
rather than the latte that you wanted. However, over time, you would add
more detail to your instructions until your chef knew exactly what to do.
A computer is like a chef who doesn’t even know how to cook. Rather
than saying “make me a coffee,” you would have to say, “Take the brown
powder from the coffee bag and add it to hot water.” Then you would
have to explain how to make hot water and how you must be careful with
the kettle and so on. This is hard work.
It turns out that the key to success as a programmer is much the same as
for many other endeavors. To become a world-renowned violin player,
you will have to practice a lot. The same is true for programming. You
must spend a lot of time working on your programs to acquire code-
writing skills. However, the good news is that just as a violin player really
enjoys making the instrument sing, making a computer do exactly what
you want turns out to be a very rewarding experience. It gets even more
enjoyable when you see other people using programs that you’ve written
and finding them useful and fun to use.
I’ve organized this book in three parts. Each part builds on the previous
one with the aim of turning you into a successful programmer. We start
off discovering the environment in which JavaScript programs run. Then
we learn the fundamentals of programming and we finish by making
some properly useful (and fun) programs.
Part 2 describes the features of the JavaScript that you use to create
programs that work on data. You will pick up some fundamental
programming skills that apply to a wide range of other languages and
that get you thinking about what it is that programs actually do. You’ll
find out how to break large programs into smaller elements and how you
can create custom data types that reflect the specific problem being
solved.
Now that you can make JavaScript programs, it’s time to have some fun
with them. You’ll discover how to create good-looking applications, learn
how to make programs that are secure and reliable, and finish off with a
bit of game development.
In each chapter, I will tell you a bit more about programming. I’ll show
you how to do something, and then I’ll invite you to make something of
your own by using what you’ve learned. You’ll never be more than a page
or so away from doing something or making something unique and
personal. After that, it’s up to you to make something amazing!
You can read the book straight through if you like, but you’ll learn much
more if you slow down and work with the practical parts along the way.
Like learning to ride a bicycle, you’ll learn by doing. You must put in the
time and practice to learn how to do it. But this book will give you the
knowledge and confidence to try your hand at programming, and it will
also be around to help you if your programming doesn’t turn out as you
expected. Here are some elements in the book that will help you learn by
doing:
Yes, the best way to learn things is by doing, so you’ll find “Make
Something Happen” elements throughout the text. These elements offer
ways for you to practice your programming skills. Each starts with an
example and then introduces some steps you can try on your own.
Everything you create will run on Windows, macOS, or Linux.
CODE ANALYSIS
If you don’t already know that programs can fail, you’ll learn this hard
lesson soon after you begin writing your first program. To help you deal
with this in advance, I’ve included “What Could Go Wrong” elements,
which anticipate problems you might have and provide solutions to those
problems. For example, when I introduce something new, I’ll sometimes
spend some time considering how it can fail and what you need to worry
about when you use the new feature.
PROGRAMMER’S POINTS
I’ve spent a lot of time teaching programming, but I’ve also written many
programs and sold a few to paying customers. I’ve learned some things
the hard way that I really wish I’d known at the start. The aim of
“Programmer’s Points” is to give you this information up front so that you
can start taking a professional view of software development as you learn
how to do it.
You’ll need a computer and some software to work with the programs in
this book. I’m afraid I can’t provide you with a computer, but in the first
chapter, you’ll find out how you can get started with nothing more than a
computer and a web browser. Later, you’ll discover how to use the Visual
Studio Code editor to create JavaScript programs.
Using a PC or laptop
You can use Windows, macOS, or Linux to create and run the programs in
the text. Your PC doesn’t have to be particularly powerful, but these are
the minimum specifications I’d recommend:
Using a Raspberry Pi
If you want to get started in the most inexpensive way possible, you can
use a Raspberry Pi running the Raspbian operating system. This has a
Chromium-compatible browser and is also capable of running Visual
Studio Code.
Downloads
In every chapter in this book, I’ll demonstrate and explain programs that
teach you how to begin to program—and you can then use that code to
create programs of your own. I’ve made a few video walkthroughs for
some crucial tasks. The book text will contain screenshots that you can
use, but these can go out of date. Follow the links to the walkthroughs to
get the latest steps to follow. You can download the book’s sample code
and video walkthroughs from the following page:
MicrosoftPressStore.com/BeginCodeJavaScript/downloads
www.begintocodewithjavascript.com
Video walkthroughs
https://bit.ly/3wEn6zX
Acknowledgments
Thanks to Mary for the cups of tea and Immy for the distraction.
We’ve made every effort to ensure the accuracy of this book and its
companion content. You can access updates to this book—in the form of a
list of submitted errata and their related corrections—at
MicrosoftPressStore.com/BeginCodeJavaScript/errata
http://www.MicrosoftPressStore.com/Support
Please note that product support for Microsoft software and hardware is
not offered through the previous addresses. For help with Microsoft
Random documents with unrelated
content Scribd suggests to you:
THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com