In how many ways functions can be defined in javascript w3schools
Answers
Answered by
1
4 ways
A Function as a Statement
function add(num1, num2) {
return num1 + num2
}
A Function as an Expression
const add = function a(num1, num2) {
return num1 + num2
}
An Arrow Function
const add = (num1, num2) => num1 + num2
Using Function Constructor
var add = Function('num1', 'num2', 'return num1 + num2')
Similar questions