Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. -Default value(data or function) for function parameters
  2. -Function Declaration -> let sayHi = function() {};
  3. -Use Arrow functions -> let sum = (a, b) => a + b;
  4. -Pass functions by name => callOneFunction(OnotherOne);
  5. -Object -> let obj = {};
  6.  
  7. To delete a property: delete obj.prop.
  8.  
  9. obj.property or obj[property]
  10.  
  11. let bag = {
  12. [fruit]: 5, // the name of the property is taken from the variable fruit
  13. };
  14.  
  15. "key" in object
  16.  
  17. for(key in object) {
  18. // executes the body for each key among object properties
  19. }
  20.  
  21. let clone = Object.assign({}, user);
  22.  
  23. let user = {
  24. sayHi() { // same as "sayHi: function()"
  25. alert("Hello");
  26. }
  27. };
  28.  
  29. let user = new User();
  30.  
  31. function sumAll(...args) { // args is the name for the array
  32. let sum = 0;
  33. for (let arg of args) sum += arg;
  34. return sum;
  35. }
  36.  
  37. let arr = [3, 5, 1];
  38. alert( Math.max(...arr) ); // 5 (spread turns array into a list of arguments)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement