Arrow functions

What are arrow functions?
Arrow functions is another very simple and concise syntax for creating functions,
that’s often better than Function Expressions and is written: a() => {},
where => is called the fat-arrow or just arrow.
In arrow function must be
1.declare after initialize (Call after definition)
2.Arrow functions work great as callbacks:, in setTimeout,forEach, map, filter reduce ...
When we defined using curley brace it explicitly return
const square = x => {
return x * x;
};
// Two parameters
const add = (a, b) => {
return a + b;
};
// Three parameters
const calculate = (x, y, z) => {
return (x + y) * z;
};
when we are not used the curley brace in arrow funtion it implicitly return
const square = x => x * x;
const add = (a, b) => a + b;
const sum = (...args) => args.reduce((a, b) => a + b, 0);
sum(1, 2, 3); // 6
// Trying to use arguments inside arrow throws ReferenceError
const noArgs = () => console.log(arguments); // ReferenceError
what are difference between arrow function and normal function?
Arrow Function
1.Does not have its own this. It inherits this from the surrounding (lexical) scope where it is defined.
2.The value of this inside an arrow function is fixed and cannot be changed by .call(), .apply(), or .bind().
3.Does not have its own arguments object. If you need access to arguments, you must use rest parameters or rely on the enclosing function's arguments.
4.Cannot be used as a constructor. Trying to use new with an arrow function throws an error..






