Michael Sabatino
New Y ork
Spotlight on K ids Can Cod e
JA VA SCRIPT
Understand ing Co ding with
Manufactured in the United States of America
CPSIA Compliance Information: Batch #BS17PK: For Fur ther Infor mation contact Rosen Publishing , New Y or k, New Y or k at 1-800-237-9932
Published in 2018 by The Rosen Publishing Group, Inc.
29 East 21st Street, New Y ork, NY 10010
Copyright 2018 by The Rosen Publishing Group, Inc.
All rights reserv ed. No part of this book may be reproduced in any for m without permission in writing from the publisher , except by a reviewer .
First Edition
Editor: Melissa Ra Shofner
Book Design: Michael J. Flynn
Photo Credits: Cover Jose Luis Pelaez Inc/Blend Images/Getty Images; p. 4 https://commons.wikimedia. org/wiki/File:Brendan_Eich_Mozilla_Foundation_ofcial_photo.jpg; p. 5 Sergey Maksienko/Shutterstock. com; p. 7 FatCamera/E+/Getty Images; p. 9 racorn/Shutterstock.com; p. 11 (top) sabrisy/Shutterstock. com; p. 11 (bottom) 1000s_pixels/Shutterstock/com; p. 12 Dragon Images/Shutterstock.com; p. 13 T eguh Jati Prasetyo/Shutterstock.com; p. 21 vgajic/E+/Getty Images.
Library of Congress Cataloging-in-Publication Data
Names: Sabatino, Michael, author .
Title: Understanding coding with JavaScript / Michael Sabatino. Description: New Y ork : PowerKids Press, [2018] | Series: Spotlight on kids can code | Includes bibliographical references and index. Identiers: LCCN 2017003086| ISBN 9781508154785 (6 pack) | ISBN 9781508155256 (pbk.) | ISBN 9781508155133 (library bound) Subjects: LCSH: JavaScript (Computer program language)--Juvenile literature. | HTML (Document markup language)--Juvenile literature. | Internet programming--Juvenile literature. | W eb sites--Authoring programs--Juvenile literature. Classication: LCC QA76.73.J39 S24 2018 | DDC 005.2/762--dc23 LC record available at https://lccn.loc.gov/2017003086
The Language of the Web ...............
A Key Ingredient ......................
Follow the Rules ......................
Plays Well with HTML .................1
Terms to Know ........................1
Lets Get Coding! ....................1
Making the Call ......................1
Game Plan ............................2
Just the Beginning ...................2
Glossary.............................2
Index................................2
Websites.............................2
Contents
Have you ever played a game or looked at a slideshow of pictures online in your web browser ? If so, then youve likely visited a web page that uses JavaScript. JavaScript is a popular programming language that brings web pages to life. From games to entire business applications such as word processors and spreadsheets, it s hard to imagine the W orld Wide We b without it.
In the mid-1990s, coder Brendan Eich wrote Moc ha, which was an early version of JavaScript. In the early days of the Internet, web pages were mostly basic text les, which were static, or unchanging. Early web pioneers wanted a way to make web pages more dynamic and interactive. That required a new programming language made specically with web pages in mind. The result was JavaScript. T oday , JavaScript is used to create all sorts of online programs that run through web browsers.
The Language of the W eb
JavaScript went through a few name changes. When Eich created it in May 1995, it was known as Mocha. It was later renamed LiveScript. In December 1995, it received its final name of JavaScript.
In 1995, JavaScript rst appeared in an early version of Netscape Navigator, one of the rst web browsers. Since that time, JavaScript has become a necessary part of all popular web browsers today . Along with HTM L and Cascading Style Sheets (CS S), JavaScript is one of the main parts of modern website design. Programmers use HTML , CSS , and JavaScript to create web pages that users can interact with by using a mouse and keyboard or a touc hscreen. However , of those three main parts, only JavaScript is considered a true programming language.
By using lines of code made up of words and symbols, web designers can use JavaScript to create interactive pages for website visitors. A page may be able to detect mouse clicks, keystrokes, and muc h more. This allows web pages to respond to users with pop-up messages, moving images, sounds, and videos.
A K ey Ingredient
JavaScript can work on most computers, even if theyre not connected to the Internet.
Before you can begin to learn about coding in any languageincluding JavaScriptyou need to know that computer programming is about following rules. This makes writing computer code a lot like playing a game, and it can be just as much fun.
Follo w the Rules
Rule 1: Coders must know what they want the computer to do and write a plan.
Rule 2: Coders must use special words to have the computer accept input , make choices, and take action.
Rule 3: Coders need to think about what tasks can be put into a group.
Rule 4: Coders need to employ logic using AND,
OR, NOT, and other key words.
Rule 5: Coders must explore the environment and understand how it works.
JavaScript is usually run on the client side. This means that the code is executed on the users computer instead of the web server that provided the web page over the Internet.
Many prog ramming language s, such as Scratch and Hops cotch, require a GUI (GOO-ee), or graphical user interf ace, in order to write code . Graph ical refe rs to graphics, which are pictur es and shapes. An interfa ce is a way two thingssuch as a computer and a usercommunicate with each o ther . How ever , JavaScr ipt doesn t need its ow n GUI. Its a written-text language and can be cre ated in any basic text-editor pr ogram.
Breaking the Code