Javatpoint Logo
Javatpoint Logo

limitTo Filter

The limitTo filter returns a new array or string containing only a specified number of elements. It chooses the elements either the beginning or the end of the source array string or number, as specified by the value and sign (positive or negative) of limit.

limitTo filter used for array: It returns an array, containing only a specified number of elements.

limitTo filter used for string: It returns a string, containing only specified number of characters.

limitTo filter used for numbers: It returns a string, containing only specified number of digits.

Syntax:

Parameter explanation:

input: It specifies array/array-like, string or number to be limited.

limit: It specifies the length of the returned array or string. If the limit number is positive, it chooses the items from the beginning of the source array/string. If the number is negative, it chooses the items from the end of the source array/string.

begin: It is optional. It specifies the index at which to begin limitation. By default, its value is 0.

Let's take an example to demonstrate limitTo filter.

See this example:

Test it Now
Next TopicLowercase Filter




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA