“fungsi normal vs fungsi panah dalam javascript” Kode Jawaban

fungsi normal vs fungsi panah dalam javascript

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

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

Fungsi Fungsi JavaScript vs Fungsi Panah

Regular functions created through function declarations / expressions are both constructible and callable. ... Arrow functions (and methods) are only callable i.e arrow functions can never be used as constructor functions. Hence, they can never be invoked with the new keyword.
Fragile Frog

aturan fungsi panah javascript

const add3 = (num1, num2, num3) => return num1 + num2 + num3;
Fantastic Falcon

aturan fungsi panah javascript

const sayHi = ()=>console.log('Hi');
Fantastic Falcon

aturan fungsi panah javascript

const square = num => num ** 2;
Fantastic Falcon

fungsi panah js vs fungsi

// currently common pattern
var that = this;
getData(function(data) {
  that.data = data;
});

// better alternative with arrow functions
getData(data => {
  this.data = data;
});
RedConcrete

Jawaban yang mirip dengan “fungsi normal vs fungsi panah dalam javascript”

Pertanyaan yang mirip dengan “fungsi normal vs fungsi panah dalam javascript”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya