On this page
Class Number
Hierarchy
- Number
Index
Constructors
Methods
Constructors
constructor
-
Parameters
value: number
The numeric value of the number.
Optional unit: string
If passed, the number's unit.
Complex units can be represented as
<unit>*<unit>*.../<unit>*<unit>*...
, with numerator units on the left-hand side of the/
and denominator units on the right. A number with only numerator units may omit the/
and the units after it, and a number with only denominator units may be represented with no units before the/
.
Returns Number
Methods
getUnit
-
Returns a string representation of this number's units. Complex units are returned in the same format that constructor accepts them.
Returns string
getValue
-
Returns the value of the number, ignoring units.
⚠️ Heads up!
This means that
96px
and1in
will return different values, even though they represent the same length.Returns number
setUnit
-
Destructively modifies this number by setting its units to
unit
, independent of its numeric value. Complex units are specified in the same format as constructor.Parameters
unit: string
Returns void
setValue
-
Destructively modifies this number by setting its numeric value to
value
, independent of its units.Parameters
value: number
Returns void
© 2006–2022 the Sass team, and numerous contributors
Licensed under the MIT License.
https://sass-lang.com/documentation/js-api/classes/types.Number
Sass's number type.