JavaScript var vs. let vs. const

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

globally

Both let and var are __-scoped if outside of a block or function, respectively.

let, var

Global variables defined with __ will not be added as properties on the global window object like those defined with __. E.g. let me = 'go'; var i = 'able'; console.log(window.me); // undefined console.log(window.i); // 'able'

const, block

The __ declaration is like "let" in that it is __-scoped. However, a constant can never be re-declared or re-assigned.

scoping

The difference between var and let is __.

block, block, block, function

The let variable declaration is always __-scoped. It is scoped to the nearest enclosing __. Keep in mind that the nearest enclosing __ might also be a __.

function, function

The var variable declaration is always __-scoped. It is scoped to the nearest enclosing __.

false. The properties of the object can still be modified.

True or false: objects declared with "const" are, as a result, immutable.


Kaugnay na mga set ng pag-aaral

Chapter 05 Quiz: Motivation and Emotion

View Set

2020A&P Quiz 1 Chapter 5 Integumentary System Study Set

View Set