Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 853 Bytes

let_and_const_exercise.md

File metadata and controls

34 lines (24 loc) · 853 Bytes

let and const Exercise

In this exercise, you’ll refactor some ES5 code into ES2015.

ES5 Global Constants

var PI = 3.14;
PI = 42; // stop me from doing this!

ES2015 Global Constants

/* Write an ES2015 Version */
const PI = 3.14;
PI = 42; //error

Quiz

  • What is the difference between var and let?
    • var allows mutability and reassignment, while let only allows mutability.
  • What is the difference between var and const?
    • var allows mutability and reassignment, while const allows neither.
  • What is the difference between let and const?
    • let allows mutability, while const does not. neither allow reassignment
  • What is hoisting?
    • when variables can be used before they are declared

Solution

See Our solution.