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?