Part IV. JavaScript for Behavior
IV
JavaScript for Behavior
Chapter 22. Getting Started with JavaScript
22
Getting Started with JavaScript
Statements and Variables
by Aaron Gustafson
In This Chapter
A simple script
Writing statements
Working with numbers
Working with text strings
Defining and using variables
Embedded versus external JavaScript
Using the JavaScript console
Up until now, you’ve been working with HTML and CSS to build web pages. They’re languages that will take you far, and you can build some powerful and interesting websites with only those tools in your toolbox. At a certain point, however, you’re probably going to want to create something HTML and CSS can’t deliver on their own. When you hit that point, you’ll need JavaScript.
JavaScript is first and foremost a programming language created to add interactivity to web pages. Want to validate a form? You can use JavaScript. Create a real-time chat application? JavaScript is your go-to. Read and write to a user’s cookies? JavaScript can do that. Load more content as a user scrolls down the page? JavaScript has you covered. Gather real-time data about how users are interacting with your pages? Yup, JavaScript can handle that too.
JavaScript is an immensely popular language. It’s an integral part of every major website and powers a bunch of popular desktop apps as well, including Adobe Photoshop, Slack, and Figma. It’s even used to run the UI astronauts have used to control spaceships! Developers who ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access