(<Function Params>) => { <Function Body> [return <Return Value>] }
(<Function Params>) => <Function Body>
//Traditional function doubleIt(x) { return 2 * x; } //Arrow-Function const doubleFct = x => 2 * x; //call arrow function const result = doubleFct(100); prn(result); //200
//Traditional function computeSum(a, b) { return a + b; } //Arrow-Function const sumFct = (a, b) => a + b; //call arrow function const sum = sumFct(10, 5); prn(sum); //15
//Traditional function computeSum(...numbers) { let sum = 0; for (let n of numbers) { sum += n; } return sum; } //Arrow-Function const sumFct = (...numbers) => { let sum = 0; for (let n of numbers) { sum += n; } return sum; }; //call arrow function const sum = sumFct(1, 2, 3); prn(sum); //6
//Traditional function getDefaultWidth() { return 10; } //Arrow-Function const getDefaultFct = () => 10; //call arrow function const width = getDefaultFct(); prn(width); //10
//Traditional function printValue(value) { console.log(value); } //Arrow-Function const fct = value => console.log(value); //call arrow function fct('Hello'); //output: Hello
//Traditional function printDefaultWidth() { console.log("200"); } //Arrow-Function const fct = () => console.log("200"); //call arrow function fct(); //output: 200