From 1287bfdb6c9ad6a18bc6b3302f887e91860767bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20F=2E=20=C3=87?= Date: Fri, 25 Oct 2019 22:52:13 +0300 Subject: [PATCH] Update arrow_function.md --- docs/JavaScript_Advance/arrow_function.md | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/JavaScript_Advance/arrow_function.md b/docs/JavaScript_Advance/arrow_function.md index 91c9ac4..355c3b9 100644 --- a/docs/JavaScript_Advance/arrow_function.md +++ b/docs/JavaScript_Advance/arrow_function.md @@ -1 +1,23 @@ -# Arrow Function +# Arrow Function +An arrow function expression is a syntactically compact alternative to a regular function expression. + +Example: +```javascript +// Regular function +function greet(name){ + console.log("Hello " + name); +} + +// Arrow function equivalent +const greet = name => { + console.log("Hello " + name) +} +``` +Both functions above are equivalent to each other. + +If we have more than one function argument then we should put them in paranthesis like this: +```javascript +const exampleFunc = (name,age,eyeColor) => { + // ... +} +```