BIND

bind() bind()๋Š” this ๊ฐ’์„ ๊ณ ์ •์‹œํ‚ค๋Š” ๋ช…๋ น! bind() ์•ˆ์˜ ์ฒซ๋ฒˆ์งธ ์ธ์ž๋Š” this ๋ฅผ ๊ณ ์ •์‹œํ‚ค๊ณ , ๋‘๋ฒˆ์งธ ์ธ์ž๋ถ€ํ„ฐ๋Š” ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋ ๋•Œ๋งˆ๋‹ค ์‚ฌ์šฉ๋œ๋‹ค. sum์ด๋ผ๋Š” ํ•จ์ˆ˜์— this๋ฅผ kim ์œผ๋กœ ๊ณ ์ •ํ•˜๋Š” ์ƒˆ๋กœ์šด ํ•จ์ˆ˜(KimSum)๊ฐ€ ๋งŒ๋“ค์–ด์ง // object ์™€ function ์‚ฌ์ด์˜ ๊ด€๊ณ„๋ฅผ ๊ทœ๋ช…ํ•ด๋ณด๊ธฐ 2 let kim = {name:'kim', first:10, second:20} let lee = {name:'lee', first:10, second:10} function sum(prefix){ return prefix +(this.first + this.second); } console.log('sum.call(kim)', sum.call(kim, '=>')); console.log('..
becky(์ง€์€)
'BIND' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก