daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. //Spread operator
  12. "use strict";
  13.  
  14. var numbers = [1, 2, 3, 4];
  15. var newNumbers = [].concat(numbers, [5, 6]);
  16.  
  17. console.log(newNumbers);
  18.  
  19. //Rest Operator
  20.  
  21. function rest() {
  22.   for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  23.     args[_key] = arguments[_key];
  24.   }
  25.  
  26.   return args.reduce(function (awal, akhir) {
  27.     return awal + akhir;
  28.   });
  29. }
  30.  
  31. console.log(rest(1, 2, 3));
  32. </script>
  33.  
  34.  
  35.  
  36. <script id="jsbin-source-javascript" type="text/javascript">//Spread operator
  37. const numbers = [1,2,3,4]
  38. const newNumbers = [...numbers, 5,6]
  39.  
  40. console.log(newNumbers)
  41.  
  42. //Rest Operator
  43.  
  44. function rest(...args) {
  45.   return args.reduce((awal, akhir) => {
  46.     return awal + akhir
  47.   })
  48. }
  49.  
  50. console.log(rest(1,2,3))</script></body>
  51. </html>
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