How to use Arrow function In Javascript
Adding two numbers using an arrow function in JavaScript involves creating a concise function syntax that adds parameters and returns the sum.
Syntax:
let addition = (a, b) => a + b;
Example: In this example we are using arrow function to add two numbers.
let addition = (a, b) => a + b;
let num1 = 25;
let num2 = 25;
let sum = addition(num1, num2);
console.log("Sum of given numbers is :", sum);
Output
Sum of given numbers is : 50
JavaScript Program to Add Two Numbers
We will explore how to add two numbers in JavaScript. Adding two numbers in JavaScript means combining numeric values together using arithmetic addition, which gives us their total sum.
There are several methods that can be used to Add Two Numbers in JavaScript, which are listed below:
Table of Content
- Using + Operator
- Using function
- Using Arrow function
- Using Addition Assignment (+=) Operator