number
Returns the Double
value of this JS value if the type is number. If not, returns nil
.
var number: Double? { get }
Returns the Double
value of this JS value if the type is number. If not, returns nil
.
var number: Double? { get }
import JavaScriptKit
Swift framework to interact with JavaScript through WebAssembly.
@dynamicMemberLookup enum JSValue
JSValue
represents a value in JavaScript.
@frozen struct Double
A double-precision, floating-point value type.
init(floatLiteral value: Double)
init(integerLiteral value: Int32)
init(nilLiteral _: ())
init(stringLiteral value: String)
static func construct(from value: JSValue) -> Self?
static func string(_ value: String) -> JSValue
var array: JSArray? { get }
var bigInt: JSBigInt? { get }
Returns the JSBigInt
of this JS value if its type is function. If not, returns nil
.
var boolean: Bool? { get }
Returns the Bool
value of this JS value if its type is boolean. If not, returns nil
.
var description: String { get }
var function: JSFunction? { get }
Returns the JSFunction
of this JS value if its type is function. If not, returns nil
.
var isNull: Bool { get }
Returns the true
if this JS value is null. If not, returns false
.
var isUndefined: Bool { get }
Returns the true
if this JS value is undefined. If not, returns false
.
var jsString: JSString? { get }
Returns the JSString
value of this JS value if the type is string. If not, returns nil
.
var jsValue: JSValue { get }
var object: JSObject? { get }
Returns the JSObject
of this JS value if its type is object. If not, returns nil
.
var string: String? { get }
Returns the String
value of this JS value if the type is string. If not, returns nil
.
var symbol: JSSymbol? { get }
Returns the JSSymbol
of this JS value if its type is function. If not, returns nil
.
subscript(index: Int) -> JSValue { get set }
An unsafe convenience method of JSObject.subscript(_ index: Int) -> JSValue
subscript(dynamicMember name: String) -> JSValue { get set }
An unsafe convenience method of JSObject.subscript(_ index: Int) -> JSValue
subscript(dynamicMember name: String) -> ((ConvertibleToJSValue...) -> JSValue) { get }
An unsafe convenience method of JSObject.subscript(_ name: String) -> ((ConvertibleToJSValue...) -> JSValue)?
func fromJSValue<Type>() -> Type? where Type : ConstructibleFromJSValue
func isInstanceOf(_ constructor: JSFunction) -> Bool
Return true
if this value is an instance of the passed constructor
function. Returns false
for everything except objects and functions.
static func function(_ body: @escaping ([JSValue]) -> JSValue) -> JSValue
Deprecated: Please create JSClosure
directly and manage its lifetime manually.
static func function(_ closure: JSClosure) -> JSValue