back to Overview

.reverse()

Returns a new Minified list or string with the input's elements/characters in reverse order.
Util module only.

Syntax Variants

list.reverse()
_.reverse(list)
_.reverse(string)

Parameters

list
A list to use as input. Can be an array, a Minified list or any other array-like structure with length property.
string
A string to use as input
(return value)
a new list or string with the input in reverse order.

Description

Returns a new Minified list or string with the input's elements/characters in reverse order. The first element is swapped with the last, the second with the second to last and so on.

Example

Changes the order of a list:

var rev = _('a', 'b', 'c').reverse(); // returns _('c', 'b', 'a')

Example

The same with an array:

var rev = _.reverse(['a', 'b', 'c']); // returns _('c', 'b', 'a')

Example

Or a string:

var rev = _.reverse("abc"); // returns _("cba")

Comments

comments powered by Disqus

back to Overview

Functions