You are here: Home / Topics / Arrow Function in JavaScript

Arrow Function in JavaScript

Filed under: JavaScript on 2023-08-07 19:00:15

In this post, we are going to show you arrow function. 

Watch the below example carefully.

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Functions</h1>
<h2>The Arrow Function</h2>

<p>This example shows the syntax of an Arrow Function, and how to use it.</p>

<p id="demo"></p>

<script>
var magic = () => new Date();
console.log(magic);
document.getElementById("demo").innerHTML = magic();
</script>

</body>
</html>
 

This will print Mon Aug 07 2023 18:56:51 GMT+0530 (India Standard Time) in the paragraph with id demo. Time is current time. I am writing this time as i have checked this function on 07 Aug 2023 at 18:56:51.

Do you want to learn JavaScript Mcqs?

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.