Getting Started with JavaScript
- JavaScript - Mozilla Developer Center
- JS Reference (DevDocs)
- JavaScript Tutorial and Reference from w3schools.com
- JavaScript for Web Designers, a short book available online through the Harvard Library.
- Jennifer Robbins, 2018. Learning Web Design: A Beginner's Guide to HTML, CSS, JavaScript, and Web Graphics, 5th ed. O'Reilly Media. 500 p. ISBN 978-1491960202
Some basics
- JS in HTML.
Including JavaScript in HTML withscriptelement, with eithersrcattribute or JS code. - Variables.
Declare variables withletand sometimesconst.
Though you will see the oldervar, which works but is not preferred. - Console is your friend.
Your browser developer tools will be critical to use, and especially the "Console". Log to the console in JS withconsole.log('hello there!'); - When is the code executed?
scriptinheador right before the body close tag -</body>
But it is good practice to rely on specific events! - Events, Listeners, and Handlers
load,click,focus,blur,submit,mouseover,mouseout,keypress.
HTML attributes are available, but don't use these.
Add event listeners through JavaScript!