It’s not so tricky like recursion for me, but this stuff is somewhat contrary to intuition.
For now ended up with this:
NOTE: it’s not a code, it’s kinda cheatsheet.
let someArray = [1, 2, 3]
//Why do i need spread operator?
//I need this stuff from the array for whatever reason,
//but I don't need it's brackets
//Assumption:
//errors below have similar nature
//we are messing with OPERATORS
console.log(typeof(*))//error
console.log(typeof(...someArray))//error
//Analogy
//Math.sqrt does stuff with one operand, with Number
//spread operator does stuff with one operand, with Array
The spread operator basically ‘spreads’ the elements inside it out of the list. I understand what it feels like to first understand the spread operator and this example helps me:
This example returns [0, 1, 2, 3, 4, 5, 6] and not [0, [1, 2, 3], 4, 5, 6]. I am still no expert myself, but this kind of helps me grasp it a little bit easier.