Getting Started with JavaScript
- MDN JavaScript
- JS Reference (DevDocs)
- W3Schools JavaScript
- Marquis, M. (2016). JavaScript for Web Designers (1st edition). A Book Apart.
- Niederst Robbins, J. (2018). Learning Web design : a beginner's guide to HTML, CSS, Javascript, and web graphics (Fifth edition.). O'Reilly.
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! - Objects
- Conditional flow.
if...else - Iterations and Loops.
for...of - Functions - named and anonymous
- DOM (Document Object Model)
- 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!