Creates a new Sass list.
The initial values of the list elements are undefined. These elements must be set using setValue before accessing them or passing the list back to Sass.
constlist = newsass.types.List(3);
list.setValue(0, newsass.types.Number(10, "px"));
list.setValue(1, newsass.types.Number(15, "px"));
list.setValue(2, newsass.types.Number(32, "px"));
list; // 10px, 15px, 32px
The number of (initially undefined) elements in the list.
Optional commaSeparator: boolean
If true, the list is comma-separated; otherwise, it's space-separated. Defaults to true.
Returns the number of elements in the list.
// list is `10px, 15px, 32px`
list.getLength(); // 3
// list is `1px solid`
list.getLength(); // 2
Returns true if this list is comma-separated and false otherwise.
// list is `10px, 15px, 32px`
list.getSeparator(); // true
// list is `1px solid`
list.getSeparator(); // false
Returns the element at index, or undefined if that value hasn't yet been set.
// list is `10px, 15px, 32px`
list.getValue(0); // 10px
list.getValue(2); // 32px
Error if index is less than 0 or greater than or equal to the number of elements in this list.
A (0-based) index into this list.
Sets whether the list is comma-separated.
true to make the list comma-separated, false otherwise.
Sets the element at index to value.
// list is `10px, 15px, 32px`
list.setValue(1, newsass.types.Number(18, "px"));
list; // 10px, 18px, 32px
Error if index is less than 0 or greater than or equal to the number of elements in this list.
A (0-based) index into this list.
© 2006–2025 the Sass team, and numerous contributors
Licensed under the MIT License.
https://sass-lang.com/documentation/js-api/classes/types.List
Sass's list type.
This list type’s methods use 0-based indexing, even though within Sass lists use 1-based indexing. These methods also don’t support using negative numbers to index backwards from the end of the list.