[var , let , const] scope - 1

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

1. var


1st. example

var abc = "test";

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

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

result

inside_block: test
outside_block: test


2nd. example

var 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

var abc;
abc = "test";

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

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

result

inside_block: 123
outside_block: test


4th. example

var 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개의 댓글