School
Advanced Javascript
Week 02
Class
Read
- Inline Event Handling
Registering event handlers. Don't use inline event registration. (separate behavior and structure) Default Action - prevent and allow. Event script is executed first and then the default action takes place after. Can't prevent unload. This keyword (owner of a function) pass as argument to store parent object
- Modern JS Functions
const myFunction = () => { //... }
Parameters are passed in the parentheses or if only one param, omit parentheses Implicit return. Wrap objects with curly braces in parenthesesconst myFunction = () => ({ value: 'test' }) myFunction() //{value: 'test'}
"this" keyword This is where regular functions should be used instead, when dynamic context is not needed. - Searching the DOM
document.getElementById(id)
Method Searches by... Can call on an element? Live? querySelector
CSS-selector ✔ - querySelectorAll
CSS-selector ✔ - getElementById
id
- - getElementsByName
name
- ✔ getElementsByTagName
tag or '*'
✔ ✔ getElementsByClassName
class ✔ ✔