this in arrow function, anonymouse function js code example
Example 1: arrow function javascript
function Welcome(){
console.log("Normal function");
}
const Welcome = () => {
console.log("Normal function");
}
Example 2: arrow function javascript
let empty = () => {};
(() => 'foobar')();
var simple = a => a > 15 ? 15 : a;
simple(16);
simple(10);
let max = (a, b) => a > b ? a : b;
var arr = [5, 6, 13, 0, 1, 18, 23];
var sum = arr.reduce((a, b) => a + b);
var even = arr.filter(v => v % 2 == 0);
var double = arr.map(v => v * 2);
promise.then(a => {
}).then(b => {
});
setTimeout( () => {
console.log('I happen sooner');
setTimeout( () => {
console.log('I happen later');
}, 1);
}, 1);