Example 1 — Lists and Strings (Official Samples)
Drop the first item of an array or the first character of a string.
console.log(R.tail([1, 2, 3])); // [2, 3]
console.log(R.tail([1])); // []
console.log(R.tail('abc')); // 'bc'
console.log(R.tail('')); // '' How It Works
- Array. The first item
1is skipped, so[2, 3]remains. - One item. Removing the only item leaves an empty array, not
undefined. - String. For text, the first character goes and a string comes back:
'bc'. - Empty. There is nothing to remove, so
''stays''without an error.
