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:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.