SHARE
TWEET

Untitled

a guest Apr 20th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Merge de array
  2. let arr1 = ["Yago", "Fernanda"];
  3. let arr2 = [...arr1, "Gabriel"];
  4.  
  5.  
  6. console.log(arr2); //["Yago", "Fernanda", "Gabriel"]
  7.  
  8. // Clone de array
  9. let arr3 = [...arr2];
  10. arr2.push("Bernardo");
  11. console.log(arr3); //["Yago", "Fernanda", "Gabriel"]
  12. console.log(arr2); //["Yago", "Fernanda", "Gabriel", "Bernardo"]
  13.  
  14. // rest paremeters
  15. function somaValores (...args) {
  16.     let soma = 0;
  17.     for (let arg of args) soma += arg;
  18.     return soma;
  19. }
  20. console.log(somaValores(4,5,1)); //10
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top