Enum boa::JsValue [−][src]
pub enum JsValue {
Null,
Undefined,
Boolean(bool),
String(JsString),
Rational(f64),
Integer(i32),
BigInt(JsBigInt),
Object(JsObject),
Symbol(JsSymbol),
}
Expand description
A Javascript value
Variants
null
- A null value, for when a value doesn’t exist.
undefined
- An undefined value, for when a field or index doesn’t exist.
Boolean(bool)
boolean
- A true
/ false
value, for if a certain criteria is met.
Tuple Fields of Boolean
0: bool
String(JsString)
String
- A UTF-8 string, such as "Hello, world"
.
Tuple Fields of String
0: JsString
Rational(f64)
Number
- A 64-bit floating point number, such as 3.1415
Tuple Fields of Rational
0: f64
Integer(i32)
Number
- A 32-bit integer, such as 42
.
Tuple Fields of Integer
0: i32
BigInt(JsBigInt)
BigInt
- holds any arbitrary large signed integer.
Tuple Fields of BigInt
0: JsBigInt
Object(JsObject)
Object
- An object, such as Math
, represented by a binary tree of string keys to Javascript values.
Tuple Fields of Object
0: JsObject
Symbol(JsSymbol)
Symbol
- A Symbol Primitive type.
Tuple Fields of Symbol
0: JsSymbol
Implementations
Strict equality comparison.
This method is executed when doing strict equality comparisons with the ===
operator.
For more information, check https://tc39.es/ecma262/#sec-strict-equality-comparison.
Abstract equality comparison.
This method is executed when doing abstract equality comparisons with the ==
operator.
For more information, check https://tc39.es/ecma262/#sec-abstract-equality-comparison
The internal comparison abstract operation SameValue(x, y), where x and y are ECMAScript language values, produces true or false.
More information:
The internal comparison abstract operation SameValueZero(x, y)
,
where x
and y
are ECMAScript language values, produces true
or false
.
SameValueZero
differs from SameValue only in its treatment of +0
and -0
.
More information:
pub fn abstract_relation(
&self,
other: &Self,
left_first: bool,
context: &mut Context
) -> JsResult<AbstractRelation>
pub fn abstract_relation(
&self,
other: &Self,
left_first: bool,
context: &mut Context
) -> JsResult<AbstractRelation>
Abstract relational comparison
The comparison x < y
, where x
and y
are values, produces true
, false
,
or undefined
(which indicates that at least one operand is NaN
).
In addition to x
and y
the algorithm takes a Boolean flag named LeftFirst
as a parameter.
The flag is used to control the order in which operations with potentially visible side-effects
are performed upon x
and y
. It is necessary because ECMAScript specifies left to right evaluation
of expressions. The default value of LeftFirst is true
and indicates that the x
parameter
corresponds to an expression that occurs to the left of the y
parameter’s corresponding expression.
If LeftFirst
is false
, the reverse is the case and operations must be performed upon y
before x
.
More Information:
The less than operator (<
) returns true
if the left operand is less than the right operand,
and false
otherwise.
More Information:
The less than or equal operator (<=
) returns true
if the left operand is less than
or equal to the right operand, and false
otherwise.
More Information:
The greater than operator (>
) returns true
if the left operand is greater than
the right operand, and false
otherwise.
More Information:
The greater than or equal operator (>=
) returns true
if the left operand is greater than
or equal to the right operand, and false
otherwise.
More Information:
Get the type of a value
This is the abstract operation Type(v), as described in https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-ecmascript-language-types.
Check JsValue::type_of if you need to call the typeof
operator.
Creates a new number with Infinity
value.
Creates a new number with -Infinity
value.
Returns true if the value is a function
Returns true if the value is undefined.
Returns true if the value is null or undefined.
Returns true if the value is integer.
Returns the string if the values is a string, otherwise None
.
Returns true if the value is a boolean.
Returns an optional reference to a BigInt
if the value is a BigInt primitive.
Set the kind of an object.
pub fn to_primitive(
&self,
context: &mut Context,
preferred_type: PreferredType
) -> JsResult<JsValue>
pub fn to_primitive(
&self,
context: &mut Context,
preferred_type: PreferredType
) -> JsResult<JsValue>
The abstract operation ToPrimitive takes an input argument and an optional argument PreferredType.
Converts the value to a BigInt
.
This function is equivelent to BigInt(value)
in JavaScript.
Returns an object that implements Display
.
Examples
use boa::JsValue;
let value = JsValue::new(3);
println!("{}", value.display());
Converts the value to a string.
This function is equivalent to String(value)
in JavaScript.
Converts the value to an Object.
This function is equivalent to Object(value)
in JavaScript
Converts the value to a PropertyKey
, that can be used as a key for properties.
It returns value converted to a numeric value of type Number
or BigInt
.
Converts a value to an integral 32 bit unsigned integer.
This function is equivalent to value | 0
in JavaScript
Converts a value to an integral 32 bit signed integer.
Converts a value to a non-negative integer if it is a valid integer index value.
Converts argument to an integer suitable for use as the length of an array-like object.
Converts a value to an integral Number value.
Converts a value to a double precision floating point.
This function is equivalent to the unary +
operator (+value
) in JavaScript
This is a more specialized version of to_numeric
, including BigInt
.
This function is equivalent to Number(value)
in JavaScript
Check if the Value
can be converted to an Object
The abstract operation RequireObjectCoercible
takes argument argument.
It throws an error if argument is a value that cannot be converted to an Object using ToObject
.
It is defined by Table 15
More information:
Converts argument to an integer, +∞, or -∞.
typeof
operator. Returns a string representing the type of the
given ECMA Value.
More information:
Trait Implementations
Performs the conversion.
Performs the conversion.
Runs Finalize::finalize() on this object and all contained subobjects Read more
Auto Trait Implementations
impl !RefUnwindSafe for JsValue
impl !UnwindSafe for JsValue
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.