write a function javascript code example
Example 1: javascript function
function myFunc(theObject) {
theObject.make = 'Toyota';
}
var mycar = {make: 'Honda', model: 'Accord', year: 1998};
var x, y;
x = mycar.make;
myFunc(mycar);
y = mycar.make;
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: how to write a function javascript
function name(argument){
return argument + 2
}
name(4)
let name = function(arg){ return arg + 2}
name(4)
let name = (arg) => {return arg+ 2}
name(4)