Example 1 — Official Samples
Add a string, add to an empty list, and add an array — the three samples from the Ramda docs.
console.log(R.append('tests', ['write', 'more'])); // ['write', 'more', 'tests']
console.log(R.append('tests', [])); // ['tests']
console.log(R.append(['tests'], ['write', 'more'])); // ['write', 'more', ['tests']] How It Works
- Copy, then add.
R.appendcopies['write', 'more']and puts'tests'at the end. - Empty list. There is nothing to copy, so the result holds only
'tests'. - Array as an item.
['tests']is added whole, so the last item is itself an array. - Same length rule. Every call returns exactly one more item than the input list.
