Normální funkce vs šipka funkce

Příklady kódu

2
0

normální funkce vs šipka funkce

// Normal Function
let add = function (num1, num2) {
return num1 + num2;
}

// Arrow Function
let add = (num1, num2) => num1 + num2;
0
0

rozdíl mezi normální funkci a šíp funkce

//* main difference is arrow functions do not have their own this
let user = {
  name: "HEllo world",
  functTest() {
    console.log("----functTest---", this.name) // HEllo world
  },
  arrowTest: () => { 
    console.log("----arrowTest----", this.name) // undefined
  }
}
user.functTest()
user.arrowTest()

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................