TIL 2021.12.21

yoojeonglee·2021년 12월 21일
0

TIL

목록 보기
1/4
post-thumbnail

-What kind of a language is JS?
Is JavaScript interpreted by design?

-Variable declaration(type): var, const, let
Variable type !== Data type
Difference: updatable/fixed & scope
var: updatable & redeclarable & global/functional scope, hoisting
Problem in variable redeclaration

var greeter = "hey hi";
var times = 4;

if (times > 3) {
   var greeter = "say Hello instead"; 
}
    
console.log(greeter) // "say Hello instead"

const: fixed(but properties of objects can be changed) & block scope
let: updatable(but not redeclared) & block scope

-hoisting: variable/function/class declaration is primarily initialized

-TDZ: before a variable's initialization

-scope
Scope refers to the visibility of variables and context refers to the value of this in the same scope.
global scope
functional scope
block scope
module scope
lexical scope

-closure
In other words, innerFunc() closes over (a.k.a. captures, remembers) the variable outerVar from its lexical scope.

profile
끝이 창대할 개발자

0개의 댓글