Example 1 — Official Samples
Read the end of a list, an empty list, and a string — the samples from the Ramda docs.
console.log(R.last(['fi', 'fo', 'fum'])); // 'fum'
console.log(R.last([])); // undefined
console.log(R.last('abc')); // 'c' How It Works
- List. The list has 3 items, so
R.lastreads index 2:'fum'. - Empty. There is no item to read, so the result is
undefined— no error is thrown. - String. A string is read like a list of characters, so
'abc'gives'c'. - Unchanged. None of the inputs are modified.
