Função de seta JavaScript
hello = () => {
return "Hello World!";
}
Ankur
hello = () => {
return "Hello World!";
}
// Arrow Functions Shorthand javascript
// Longhand:
function sayHello(name) {
console.log('Hello', name);
}
sayHello("Chetan"); // Hello Chetan
setTimeout(function() {
console.log('Loaded'); //Loaded
}, 2000);
[1,2,3].forEach(function(item) {
console.log(item);
// 1
// 2
// 3
});
// Shorthand:
sayHello = name => console.log('Hello', name);
sayHello("Chetan"); //Hello Chetan
setTimeout(() => console.log('Loaded'), 2000); //Loaded
[1,2,3].forEach(item => console.log(item));
// 1
// 2
// 3
const square = num => num ** 2;