new function in javascript code example
Example 1: create function javascript
function myFunction(p1, p2) {
return p1 * p2;
}
Example 2: how to make a function in javascript
function test(arg1,arg2,arg3) {
console.log(arg1 + ', ' + arg2 + ', ' + arg3)
}
test('abc','123','xyz');
Example 3: new function in javascript
var x=7;
function A(){
var x=70;
function B(){
console.log(x);
}
let C = function(){
console.log(x);
}
let D = new Function('console.log(x)');
B();
C();
D();
};
A();
Example 4: new function javascript
var add = function(num1, num2) {
return num1 + num2
}