๐ย Reference
๐ย Chapter
with
๋ฌธ์ ํธ์๋ฅผ ์ํด ๋ง๋ค์ด์ก์ง๋ง, ์ฑ๋ฅ๊ณผ ์ฝ๋ ์์ ์ฑ ๋ฌธ์ ๋ก ์ธํด ๋ ์ด์ ์ฌ์ฉํ์ง ์๋ ๊ฒ์ด ์ข๋ค.with
๋ฌธ์ ํน์ ๊ฐ์ฒด๋ฅผ ๋ฒ์(scope)๋ก ์ค์ ํ์ฌ, ํด๋น ๊ฐ์ฒด์ ์์ฑ์ ์ ๊ทผํ ๋ ๋งค๋ฒ ๊ฐ์ฒด ์ด๋ฆ์ ๋ฐ๋ณตํด์ ์ฐ์ง ์๋๋ก ํด์ค๋ค.// 'with' ๋ฌธ ์ฌ์ฉ ์
const person = {
name: '์ง๋',
age: 30,
city: '์์ธ'
};
console.log(person.name);
console.log(person.age);
console.log(person.city);
// 'with' ๋ฌธ ์ฌ์ฉ ํ
const person = {
name: '์ง๋',
age: 30,
city: '์์ธ'
};
with (person) {
console.log(name);
console.log(age);
console.log(city);
}
with (person)
๋ธ๋ก ์์์๋ person.name
๋์ name
์ผ๋ก ๋ฐ๋ก ์์ฑ์ ์ ๊ทผํ ์ ์๋ค.