JavaScript For Kids For Dummies
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright 2015 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions
.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc., and may not be used without written permission. JavaScript is a registered trademark of Oracle, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport
.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com
. For more information about Wiley products, visit www.wiley.com
.
Library of Congress Control Number: 2015945282
ISBN 978-1-119-11986-9 (pbk); ISBN 978-1-119-11989-0 (ebk); ISBN 978-1-119-11988-3
JavaScript For Kids For Dummies
Visit www.dummies.com/cheatsheet/javascriptforkids to view this book's cheat sheet.
- Table of Contents
Guide
Pages
Introduction
JavaScript For Kids For Dummies is an introduction to the basics of JavaScript coding. In each chapter, we walk you step-by-step through creating JavaScript programs for the web. Designed for kids of all ages, with no coding experience, we strive to introduce this technical topic in a fun, engaging, and interactive way.
JavaScript is the most widely used programming language in the world today. Thats why we think youve made a great decision by beginning your journey into the world of coding by picking up this book.
JavaScript is fun and easy to learn! With some determination and imagination, youll be on your way to creating your very own JavaScript programs in no time!
Just as the only way to Carnegie Hall is to practice, practice, practice, the only way to become a better programmer is to code, code, code!
About This Book
We seek to de-code the language of JavaScript for you and give you an understanding of the concepts. With the ability to move at your own pace, JavaScript For Kids For Dummies will get you up to speed. In this book, you learn how to create fun games and programs. We even show you how to customize and build your own versions of the games that you can post to the web and share with your friends!
Whether you know a little JavaScript or youve never seen it before, this book shows you how to write JavaScript the right way.
Topics covered in this book include the following:
- The basic structures of JavaScript programs
- JavaScript expressions and operators
- Structuring your programs with functions
- Writing loops
- Working with JavaScript, HTML5, and CSS3
- Making choices with ifelse statements
Learning JavaScript isnt only about learning how to write the language. Its also about accessing the tools and the community that has been built around the language. JavaScript programmers have refined the tools and techniques used to write JavaScript over the languages long and exciting history. Throughout this book, we mention important techniques and tools for testing, documenting, and writing better code!
To make this book easier to read, youll want to keep in mind a few tips. First, all JavaScript code and all HTML and CSS markup appears in monospaced type like this:
document.write("Hi!");
The margins on a book page dont have the same room as your monitor likely does, so long lines of HTML, CSS, and JavaScript may break across multiple lines. Remember that your computer sees such lines as single lines of HTML, CSS, or JavaScript. We indicate that everything should be on one line by breaking it at a punctuation character or space and then indenting any overage, like so:
document.getElementById("thisIsAnElementInTheDocument").addEventListener("click",doSomething,false);
HTML and CSS dont care very much about whether you use uppercase or lowercase letters or a combination of the two. But, JavaScript cares a lot! In order to make sure that you get the correct results from the code examples in the book, always stick to the same capitalizations that we use.
Foolish Assumptions
You dont need to be a programming ninja or a hacker to understand programming. You dont need to understand how the guts of your computer work. You dont even need to know how to count in binary.
However, we do need to make a couple of assumptions about you. We assume that you can turn your computer on, that you know how to use a mouse and a keyboard, and that you have a working Internet connection and web browser. If you already know something about how to make web pages (it doesnt take much!), youll have a jumpstart on the material.
The other things you need to know to write and run JavaScript code are details we cover in this book, and the one thing youll find to be true is that programming requires attention to details.
Icons Used In This Book
Heres a list of the icons we use in this book to flag text and information thats especially noteworthy.
This icon highlights technical details that you may or may not find interesting. Feel free to skip this information, but if youre the techie type, you might enjoy reading it.
Next page