JavaScript Arrow Function

Arrow functions were introduced in ES6. allow us to write shorter function syntax:

below demo function is an arrow function returning hello World String.

The paragraph div content will be replaced by demo function text.

Code Example:

output: hello Shri

Note: If the function has only one statement, and the statement returns a value, you can remove the brackets and the return keyword.  for multiple statement, the last statement should return value if returning data.

Arrow function with args:

Output:

hello World

Hello Karthik

Note: above code , hello arrow function is created with one argument .

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top