1var x = myFunction(4, 3); // Function is called, return value will end up in x
2
3function myFunction(a, b) {
4 return a * b; // Function returns the product of a and b
5}
1function myFunc(theObject) {
2 theObject.make = 'Toyota';
3}
4
5var mycar = {make: 'Honda', model: 'Accord', year: 1998};
6var x, y;
7
8x = mycar.make; // x gets the value "Honda"
9
10myFunc(mycar);
11y = mycar.make; // y gets the value "Toyota"
12 // (the make property was changed by the function)
13
1// variable:
2var num1;
3var num2;
4// function:
5function newFunction(num1, num2){
6 return num1 * num2;
7}
1function myFunc(param) {
2 return param
3}
4console.log(myFunc("Hello World"))