Example 1 — Official Array Samples
Drop the last item, down to an empty list.
console.log(JSON.stringify(R.init([1, 2, 3]))); // [1,2]
console.log(JSON.stringify(R.init([1]))); // []
console.log(JSON.stringify(R.init([]))); // [] How It Works
- Three items. The last one,
3, is dropped, leaving[1, 2]. - One item. That item is also the last, so nothing is left:
[]. - Empty list. Nothing to drop; you still get
[], not an error. - Printing.
JSON.stringifyjust makes the arrays easy to read.
