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 addfunc(a, b) {
2 return a + b;
3 // standard long function
4}
5
6addfunc = (a, b) => { return a + b; }
7// cleaner faster way creating functions!
8
1the function of javascript is to teach first year programers
2synactically correct language constructs by way of an anti-pattern.
3
1// 3 ways you see it
2function name(argument){
3 return argument + 2
4 //return something here
5}
6name(4) // equals 6
7
8let name = function(arg){ return arg + 2}
9name(4) //this equals 6, here we are calling our name function
10
11//es6 style
12
13let name = (arg) => {return arg+ 2}
14name(4) //equals 6