text: // ECMAScript or ES6: Rest Op, Spread Op
  
  /* Purpose of Rest and Spread: help in condensing the volume of code,
  and improve readability.
  */
  
  // rest: used to condense an indeterminate no. of parameters into a single array
  // spread: used over (arrays/objects/strings) to split iterables into individual args.
  
  /* ...rest */
  function add(...numbers) {
      return numbers.reduce((sum, number) => sum+number, 0)
  }
  console.log(add(1,2,3,4)); // returns 10
  console.log(add(1,2,3,4,5,6,7,8,9,10)) // returns 55
  
  // Must appear at the end of list of parameters,
  // used when we don't kow the no. of parameters
  
  function add(num1, num2, ...numbers) {
      return numbers.reduce((sum, number) => sum + number, num1 + num2)
  }
  console.log(add(1,2,3,4)); // returns 10
  console.log(add(1,2,3,4,5,6,7,8,9,10)) // returns 55
  
  /* ...spread */
  
  //ES5 Way first
  var arr1 = [1,2,3];
  var arr2 = [4,5,6];
  // Concatenate an array
  var arr3 = arr1.concat(arr2);
  console.log(arr3) // Returns [1, 2, 3, 4, 5, 6] in a console.log
  
  // Copying an array
  var arr4 = arr2;
  console.log(arr4) // Returns [4, 5, 6] in a console.log
  // Note: there is a risk when copying an array in this manner, see explanation after this code block
  
  // Expanding an array
  var arr5 = [1,2,3];
  var expanded = [arr5, 4, 5];
  console.log(expanded) // Returns [[1, 2, 3], 4, 5] in a console.log
  
  // String to Array
  var string = "stefan";
  var split = string.split("")
  console.log(split) // Returns ['s', 't', 'e', 'f', 'a', 'n'] in a console.log
  
  // Math functions
  var max = Math.max(arr1);
  console.log(max) // Returns NaN in a console.log
  
  /*
  NOTE: In the "copying" example I noted that that way of work is susceptible to error, 
  the reason for this is that in ES5 when you "copy" an array you are actually copying the reference to it, 
  so if you update your "new" variable, you will actually update both copies of the array. 
  Let me show you an example:
  */
  
  var arr1 = [1,2,3];
  var arr2 = arr1;
  arr2.push(4);
  console.log(arr1); // Returns [1, 2, 3, 4] in a console.log
  console.log(arr2); // Returns [1, 2, 3, 4] in a console.log
  
  /* ...spread now:
  Using Spread Op, we can create a new list of args,
  this allow us to treat new var/let/const as completely new items
  */
  
  let arr1 = [1,2,3];
  let arr2 = [4,5,6];
  
  let arr1 = [1,2,3];
  let arr2 = [4,5,6];
  
  // Concatenate an array
  let arr3 = [...arr1, arr2];
  console.log(arr3) // Returns [1, 2, 3, 4, 5, 6] in a console.log
  // Note, the spread operator is ok in an example like this, but it is not recommended in potentially large application as it can cause excessive memory usage and risks of Stack Overflow errors. Using .concat is safer here
  
  // Copying an array
  let arr4 = [...arr2];
  console.log(arr4) // Returns [4, 5, 6] in a console.log
  
  // Expanding an array
  let arr5 = [1,2,3];
  let expanded = [...arr5, 4, 5];
  console.log(expanded) // Returns [1, 2, 3, 4, 5] in a console.
  
  // String to Array
  let string = "stefan";
  let split = [...string]
  console.log(split) // Returns ['s', 't', 'e', 'f', 'a', 'n'] in a console.log
  
  // Math functions
  let max = Math.max(...arr1);
  console.log(max) // Returns 3 in a console.log
  
  
  
  
  