Class
JSArray
public class JSArray: JSBridgedClass
A wrapper around the JavaScript Array class that exposes its properties in a type-safe and Swifty way.
Relationships
Nested Types
JSArray.Iterator
Conforms To
JSBridgedClassConform to this protocol when your Swift class wraps a JavaScript class.
RandomAccessCollection
Nested Type Aliases
Initializers
init?(from:)
public required convenience init?(from value: JSValue)
init?(_:)
public convenience init?(_ jsObject: JSObject)
Construct a JSArray from Array JSObject.
Return nil if the object is not an Array.
Parameters
| Name | Type | Description |
|---|---|---|
| object | A |
init(unsafelyWrapping:)
public required init(unsafelyWrapping jsObject: JSObject)
Properties
constructor
public static let constructor = JSObject.global.Array.function!
startIndex
public var startIndex: Int
endIndex
public var endIndex: Int
length
public var length: Int
The number of elements in that array including empty hole.
Note that length respects JavaScript's Array.prototype.length
count
public var count: Int
The number of elements in that array not including empty hole.
Note that count syncs with the number that Iterator can iterate.
See also: JSArray.length
Methods
makeIterator()
public func makeIterator() -> Iterator