Notice
Recent Posts
Recent Comments
Link
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Tags more
Archives
Today
Total
관리 메뉴

난 정말 최고야 멋있어

[JS] Arrow Funciton 본문

카테고리 없음

[JS] Arrow Funciton

n00bh4cker 2020. 1. 6. 15:54

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]
}
*/