Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Javascript - Fundamental

Back


Statement


Comment


Syntax


Values


Identifiers / Names


Keywords


Operators


Expressions


Scope


Block Scope


Function scope

Function Arguments

function myFunction() {
  var carName = "Volvo"; // Function Scope
}
function myFunction() {
  let carName = "Volvo"; // Function Scope
}
function myFunction() {
  const carName = "Volvo"; // Function Scope
}

Global Scope


The Lifetime of JavaScript Variables


Hoisting


Strict Mode: use strict

"use strict";
// x = 3.14; // ReferenceError: x is not defined

myFunction();

function myFunction() {
  y = 3.14; // ReferenceError: y is not defined
}
x = 3.14; // This will not cause an error.
myFunction();

function myFunction() {
  "use strict";
  y = 3.14; // ReferenceError: y is not defined
}

Debugging

<script>
  let x = 15 * 5;
  debugger; // stop execution
  console.log(x);
</script>

TOP