Is a cross-platform, object-oriented scripting language used to make webpages interactive.

Javascript Java
not strict very strict
browser-only JVM
OOP Scriping - prototype Classic OOP
Arrays - is a global object that is used in the construction of arrays; which are high-level, list-like objects.
  • Inherits from Object
  • Performance is good with small data set
  • Can be modified, length not fixed
var languages = ['PHP', 'JAVA', 'Python'];
Variables
  • var - global scope, local scope if initialized in function
  • let - block scope
  • const - also block scope, but can't be modified
  • case sensitive - "var x" & "var X" are two different variables!
  • *Best practice - Use "const", if value change then use "let".
Hositing - behavior where variable and function (not expression) declarations gets pushed to the top.

Due to hoisting, "x" gets hoisted to outer scope, therefore "x" value can be retrived.

if (true) {
  var x = 1;
} 
console.log(x) // 1
Due to function (local scope), "x" does not update outer scope, therefore "x" value is not defined.
function foo() {
  var x = 1;
} 
foo();
console.log(x) // not defined
Comments
  • Single line:
    // I am a single line comment
  • Multi line:
    /* I am a 
        multi line comment */