Immutable Arrays

Copy an array…

clone = array => [...array]

Add something to the end of an array…

push = array => [...array, thing]

Remove the last item in an array…

pop = array => array.slice(0,1)

…or the first item…

shift = array => array.slice(1)

or an item at a specific index…

delete = i => array => [...array.slice(0,i), ...array.slice(i+1)]

If you are unsure whether a method mutates or not then checkout

Thank you Luke Jackson.


Now read this

Getting Truffle to Work With React

Truffle is a handy tool that helps you compile and deploy smart contracts. I ran into a bunch of gotchas the first time I tried setting a project up with truffle and react, so I’m going to walk your through the basics. Truffle has made... Continue →