Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -Default value(data or function) for function parameters
- -Function Declaration -> let sayHi = function() {};
- -Use Arrow functions -> let sum = (a, b) => a + b;
- -Pass functions by name => callOneFunction(OnotherOne);
- -Object -> let obj = {};
- To delete a property: delete obj.prop.
- obj.property or obj[property]
- let bag = {
- [fruit]: 5, // the name of the property is taken from the variable fruit
- };
- "key" in object
- for(key in object) {
- // executes the body for each key among object properties
- }
- let clone = Object.assign({}, user);
- let user = {
- sayHi() { // same as "sayHi: function()"
- alert("Hello");
- }
- };
- let user = new User();
- function sumAll(...args) { // args is the name for the array
- let sum = 0;
- for (let arg of args) sum += arg;
- return sum;
- }
- let arr = [3, 5, 1];
- alert( Math.max(...arr) ); // 5 (spread turns array into a list of arguments)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement