es6 anonymous function code example
Example 1: js anonymous function es6
var multiplyES5 = function(x, y) {
return x * y;
};
const multiplyES6 = (x, y) => { return x * y };
Example 2: anonymous function javascript
function hello() { }
hello()
var hello = function() { }
hello()
setTimeout(function(){ }, 1000)
$('.some-element').each(function(index){ })
(function(){ })()
Example 3: Arrow Functions
const magic = function() {
return new Date();
};
const magic = () => {
return new Date();
};
const magic = () => new Date();
Example 4: arrow function map js
const exampleArray = ['aa','bbc','ccdd'];
console.log(exampleArray.map(a => a.length));
Example 5: js anonymous functions
var multiplyES5 = function(x, y) {
return x * y;
};
const multiplyES6 = (x, y) => { return x * y };
Example 6: anonymous function javascript
Array.forEach((arguments) => {
})
function forEach(arguments) {
}