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 with
script
element, with eithersrc
attribute or JS code. - Variables. Declare variables with
let
and sometimesconst
.
Though you will see the oldervar
, but generally avoid that. - Console is your friend. Your browser developer tools will be critical to use, and
especially the "Console". Log to the console in JS with
console.log('hello there!');
- When is the code executed?
script
inhead
or right before the body close tag -</body>
But it is good practice to rely on specific events! - Events - load, click, focus, blur, submit, mouseover, mouseout, keypress.
HTML attributes are available, but don't use these. Add event listeners through JavaScript!