[var , let , const] scope - 2

soom·2020년 8월 17일
1
post-thumbnail
post-custom-banner

2. let


1st. example

let abc = "test"

function example() {
  console.log("inside_block: ", abc);
}

example();
console.log("outside_block: ", abc);

result

inside_block: test
outside_block: test


2nd. example

let abc;
abc = "test";

function example() {
  console.log("inside_block: ", abc);
}

example();
console.log("outside_block: ", abc);

result

inside_block: test
outside_block: test


3rd. example

let abc;
abc = "test";

function example() {
  let abc = 123;
  console.log("inside_block: ", abc);
}

example();
console.log("outside_block: ", abc);

result

inside_block: 123
outside_block: test


4th. example

let abc;
abc = "test";

function example() {
  abc = 123;
  console.log("inside_block: ", abc);
}

example();
console.log("outside_block: ", abc);

result

inside_block: 123
outside_block: 123


profile
yeeaasss rules!!!!
post-custom-banner

0개의 댓글