JavaScript Characteristics
Java vs JavaScript
Variables
1. Declared with let if the value needs to change let x = 10; 2. Declared with const if the value does need to change const x = 10; Preference should be const. 3. Do not use var - outdated syntax that ignores the scope. Still used for some specific reasons (when we ignore scope). Unless you have a reason, don’t use it.
Falsy values in JS
falsy (evaluate to false): false, 0, ‘’, null, undefined, NaN
Truthy values in JS
truthy (evaluate to true): everything else
Scope
Global Scope
Variables defined outside of a function are available everywhere, even in other js files that are included in the HTML.
Block Scope
Works like block scope in Java.
Function Scope
Variable can be used anywhere in a function that it is declared in.
Arrays
Methods (not a complete list)
Object Literals