JsValue Struct
A JavaScript value: undefined, null, a boolean, a number, a string, a symbol, a BigInt or an object. The default value is undefined. Numbers are not allocated; the other values reference a JsCell.
public readonly struct JsValue : IEquatable<JsValue>- Implements
Constructors
| Name | Description |
|---|---|
| JsValue(double) | Creates a number value. |
JsValue(double)
JsValue.csProperties
| Name | Description |
|---|---|
| False | Gets the false value. |
| IsBigInt | Gets whether the value is a BigInt. |
| IsBoolean | Gets whether the value is a boolean. |
| IsCallable | Gets whether the value is a function (an object with a [[Call]] internal method). |
| IsNull | Gets whether the value is null. |
| IsNullOrUndefined | Gets whether the value is undefined or null. |
| IsNumber | Gets whether the value is a number. |
| IsObject | Gets whether the value is an object. |
| IsString | Gets whether the value is a string. |
| IsSymbol | Gets whether the value is a symbol. |
| IsUndefined | Gets whether the value is undefined. |
| Kind | Gets the type of the value. |
| Null | Gets the null value. |
| True | Gets the true value. |
| Undefined | Gets the undefined value. |
False
JsValue.csIsBigInt
JsValue.csIsBoolean
JsValue.csIsCallable
JsValue.csIsNull
JsValue.csIsNullOrUndefined
JsValue.csIsNumber
JsValue.csIsObject
JsValue.csIsString
JsValue.csIsSymbol
JsValue.csIsUndefined
JsValue.csKind
JsValue.csNull
JsValue.csTrue
JsValue.csUndefined
JsValue.csMethods
| Name | Description |
|---|---|
| AsBigInt() | Gets the integer of a BigInt value. |
| AsBoolean() | Gets the boolean of a boolean value. |
| AsNumber() | Gets the number of a number value. |
| AsObject() | Gets the object of an object value. |
| AsString() | Gets the string of a string value. |
| AsSymbol() | Gets the symbol of a symbol value. |
| Equals(JsValue) | Compares two values with the SameValue algorithm (https://tc39.es/ecma262/#sec-samevalue). |
| Equals(object?) | Compares the value with another JsValue with the SameValue algorithm. |
| FromBigInt(BigInteger) | Creates a BigInt value. |
| FromBoolean(bool) | Creates a boolean value. |
| FromNumber(double) | Creates a number value. |
| FromObject(JsObject?) | Creates an object value, or null when the object is null. |
| FromString(string) | Creates a string value. |
| GetHashCode() | Gets a hash code consistent with SameValue. |
| ToString() | Returns a representation of the value for debugging; it never runs JavaScript code (use ToString of JsOperations for the ToString operation). |
| TryGetBoolean(bool) | Gets the boolean of the value; returns false when the value is not a boolean (no conversion). |
| TryGetNumber(double) | Gets the number of the value; returns false when the value is not a number (no conversion). |
| TryGetObject() | Gets the object of the value, or null when the value is not an object. |
| TryGetString(string?) | Gets the string of the value; returns false when the value is not a string (no conversion). |
AsBigInt()
JsValue.csGets the integer of a BigInt value.
public BigInteger AsBigInt()Returns
Exceptions
InvalidOperationException- The value is not a BigInt (use
JsEngine.ToBigIntto convert it).
AsBoolean()
JsValue.csGets the boolean of a boolean value.
public bool AsBoolean()Returns
Exceptions
InvalidOperationException- The value is not a boolean (use
JsValue.TryGetBoolean, orJsEngine.ToBooleanto convert it).
AsNumber()
JsValue.csGets the number of a number value.
public double AsNumber()Returns
Exceptions
InvalidOperationException- The value is not a number (use
JsValue.TryGetNumber, orJsEngine.ToNumberto convert it).
AsObject()
JsValue.csGets the object of an object value.
public JsObject AsObject()Returns
Exceptions
InvalidOperationException- The value is not an object (use
JsValue.TryGetObject, orJsEngine.ToObjectto convert it).
AsString()
JsValue.csGets the string of a string value.
public string AsString()Returns
Exceptions
InvalidOperationException- The value is not a string (use
JsValue.TryGetString, orJsEngine.ToStringto convert it).
AsSymbol()
JsValue.csGets the symbol of a symbol value.
public JsSymbol AsSymbol()FromBigInt(BigInteger)
JsValue.csCreates a BigInt value.
public static JsValue FromBigInt(BigInteger value)FromBoolean(bool)
JsValue.csFromNumber(double)
JsValue.csFromObject(JsObject?)
JsValue.csFromString(string)
JsValue.csGetHashCode()
JsValue.csToString()
JsValue.csTryGetBoolean(bool)
JsValue.csTryGetNumber(double)
JsValue.csTryGetObject()
JsValue.csTryGetString(string?)
JsValue.csOperators
| Name | Description |
|---|---|
| operator ==(JsValue, JsValue) | Compares two values with the SameValue algorithm. |
| implicit operator JsValue(JsObject?) | Converts an object to a value (null when the object is null). |
| implicit operator JsValue(JsSymbol) | Converts a symbol to a value. |
| implicit operator JsValue(bool) | Converts a boolean to a value. |
| implicit operator JsValue(double) | Converts a number to a value. |
| implicit operator JsValue(int) | Converts a number to a value. |
| implicit operator JsValue(string) | Converts a string to a value. |
| operator !=(JsValue, JsValue) | Compares two values with the SameValue algorithm. |