back to Overview

_()

Creates a new Minified list.
Util module only.

Syntax

_(item...)

Parameters

item
an item to add to the new list. If it is a list (as defined by _.isList()), its content will be to the new ##Minified list#list## (but NOT recursively).

Description

Creates a new Minified list. Supports variable arguments so you can add items directly to the list. For arguments that are lists (as defined by _.isList()), the list content will be added to the new list. Unlike $()#, this is not done recursively and thus you can create a list of lists by wrapping arguments in a list. Another difference between _() and $() is that $() will automatically remove null values while _() will keep them.

Example

Creating an empty list:

_()

Example

Creating a list with three items:

_(1, 2, 3)

Example

Creating the same list, but by passing an array. One array level will be flattened:

_([1, 2, 3])

Example

Creating a list containing the arrays [1, 2] and [3, 4].

_([[1, 2], [3, 4]])

Example

Merging two lists:

var a = _("a", "b", "c");
var b = _("x", "y", "z");
var merged = _(a, b);    // contains _("a", "b", "c", "x", "y", "z")

Example

Adding two elements to a list:

var a = _(1, 2, 3);
var a4 = _(a, 4);       // contains _(1, 2, 3, 4)

Example

Mixing different list types and single elements:

_(1, [], [2, 3], _(), _(4, 5)); // same content as _(1, 2, 3, 4, 5)

Comments

comments powered by Disqus

back to Overview

Functions