난 정말 최고야 멋있어
[JS] Arrow Funciton 본문
An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords. Arrow function expressions are ill suited as methods, and they cannot be used as constructors.
arrow function 은 this 등의 바인딩이 없다는 것에 주의..
몽구스에서 인스턴스 메서드를 정의할 때 Arrow Function 을 사용하지 말라고 한다!
arrow = ()=> console.log(this)
func = function () {console.log(this)}
arrow();
// {}
func()
/*
Object [global] {
global: [Circular],
clearInterval: [Function: clearInterval],
clearTimeout: [Function: clearTimeout],
setInterval: [Function: setInterval],
setTimeout: [Function: setTimeout] { [Symbol(util.promisify.custom)]: [Function] },
queueMicrotask: [Function: queueMicrotask],
clearImmediate: [Function: clearImmediate],
setImmediate: [Function: setImmediate] {
[Symbol(util.promisify.custom)]: [Function]
},
arrow: [Function: arrow],
func: [Function: func]
}
*/