Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. const numbers = [1,2,3];
  2.  
  3.  
  4. //Spread Operator
  5. const newNumbers = [...numbers,4];
  6. //const newNumbers = [numbers,4];
  7. console.log(newNumbers);
  8.  
  9.  
  10.  
  11. //Rest Operator
  12. const person = {
  13. name:'Max'
  14. };
  15. const newPerson = {
  16. ...person,
  17. age: 28
  18. };
  19. console.log(newPerson);
  20.  
  21. const filter = (...args) => {
  22. return args.filter(el => el === 1);
  23. } //Strict Equality Comparison
  24.  
  25. console.log(filter(1,2,3));
  26.  
  27.  
  28.  
  29. //ArrayDestructing
  30. [a,b]= ['Hellow','Max'];
  31. console.log(a); // it could print actually
  32. console.log(b);
  33.  
  34. const number = [1,2,3];
  35. [num1, , num3] = number;
  36. console.log(num1,num3);
  37.  
  38. //ObjectDestructing //not supported by JSbin
  39. // {name} = {name:'Max', age:28};
  40. // console.log(name);
  41. // console.log(age);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement