The abstract operation AllocateArrayBuffer with arguments constructor and byteLength is used to create an ArrayBuffer object. It performs the following steps:
"%ArrayBufferPrototype%"
, «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).The abstract operation IsDetachedBuffer with argument arrayBuffer performs the following steps:
The abstract operation DetachArrayBuffer with argument arrayBuffer performs the following steps:
NOTE Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0. No operations defined by this specification use the DetachArrayBuffer abstract operation. However, an ECMAScript implementation or host environment may define such operations.
The abstract operation CloneArrayBuffer takes three parameters, an ArrayBuffer srcBuffer, an integer srcByteOffset and optionally a constructor function cloneConstructor. It creates a new ArrayBuffer whose data is a copy of srcBuffer’s data starting at srcByteOffset. This operation performs the following steps:
The abstract operation GetValueFromBuffer takes four parameters, an ArrayBuffer arrayBuffer, an integer byteIndex, a String type, and optionally a Boolean isLittleEndian. This operation performs the following steps:
"Float32"
, then
"Float64"
, then
"U"
, then
The abstract operation SetValueInBuffer takes five parameters, an ArrayBuffer arrayBuffer, an integer byteIndex, a String type, a Number value, and optionally a Boolean isLittleEndian. This operation performs the following steps:
"Float32"
, then
"Float64"
, then
The ArrayBuffer constructor is the %ArrayBuffer% intrinsic object and the initial value of the ArrayBuffer
property of the global object. When called as a constructor it creates and initializes a new ArrayBuffer object.
ArrayBuffer
is not intended to be called as a function and will throw an exception when called in that
manner.
The ArrayBuffer
constructor is designed to be subclassable. It may be used as the value of an
extends
clause of a class definition. Subclass constructors that intend to inherit the specified
ArrayBuffer
behaviour must include a super
call to the ArrayBuffer
constructor to
create and initialize subclass instances with the internal state necessary to support the ArrayBuffer.prototype
built-in methods.
ArrayBuffer called with argument length performs the following steps:
The value of the [[Prototype]] internal slot of the ArrayBuffer constructor is the intrinsic object %FunctionPrototype% (19.2.3).
Besides its length
property (whose value is 1), the ArrayBuffer constructor has the following
properties:
The isView function takes one argument arg, and performs the following steps are taken:
The initial value of ArrayBuffer.prototype is the intrinsic object %ArrayBufferPrototype% (24.1.4).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
ArrayBuffer[@@species]
is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:
The value of the name
property of this function is "get [Symbol.species]"
.
NOTE ArrayBuffer prototype methods normally use their this
object’s
constructor to create a derived object. However, a subclass constructor may over-ride that default behaviour by
redefining its @@species property.
The ArrayBuffer prototype object is the intrinsic object %ArrayBufferPrototype%. The value of the [[Prototype]] internal slot of the ArrayBuffer prototype object is the intrinsic object %ObjectPrototype% (19.1.3). The ArrayBuffer prototype object is an ordinary object. It does not have an [[ArrayBufferData]] or [[ArrayBufferByteLength]] internal slot.
ArrayBuffer.prototype.byteLength
is an accessor property whose set accessor function
is undefined. Its get accessor function performs the following steps:
The initial value of ArrayBuffer.prototype.constructor
is the intrinsic object %ArrayBuffer%.
The following steps are taken:
The initial value of the @@toStringTag property is the String value "ArrayBuffer"
.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
ArrayBuffer instances inherit properties from the ArrayBuffer prototype object. ArrayBuffer instances each have an [[ArrayBufferData]] internal slot and an [[ArrayBufferByteLength]] internal slot.
ArrayBuffer instances whose [[ArrayBufferData]] is null are considered to be detached and all operators to access or modify data contained in the ArrayBuffer instance will fail.
The abstract operation GetViewValue with arguments view, requestIndex, isLittleEndian, and type is used by functions on DataView instances is to retrieve values from the view's buffer. It performs the following steps:
The abstract operation SetViewValue with arguments view, requestIndex, isLittleEndian, type, and value is used by functions on DataView instances to store values into the view's buffer. It performs the following steps:
NOTE The algorithms for GetViewValue and SetViewValue are identical except for their final steps.
The DataView constructor is the %DataView% intrinsic object and the initial value of the DataView
property
of the global object. When called as a constructor it creates and initializes a new DataView object. DataView
is not intended to be called as a function and will throw an exception when called in that manner.
The DataView
constructor is designed to be subclassable. It may be used as the value of an
extends
clause of a class definition. Subclass constructors that intend to inherit the specified
DataView
behaviour must include a super
call to the DataView
constructor to create
and initialize subclass instances with the internal state necessary to support the DataView.prototype
built-in methods.
DataView
called with arguments buffer, byteOffset, and length performs the following steps:
"%DataViewPrototype%"
, «[[DataView]], [[ViewedArrayBuffer]], [[ByteLength]],
[[ByteOffset]]» ).The value of the [[Prototype]] internal slot of the
DataView
constructor is the intrinsic object %FunctionPrototype% (19.2.3).
Besides the length
property (whose value is 3), the DataView constructor has the following properties:
The initial value of DataView.prototype
is the intrinsic object %DataViewPrototype% (24.2.4).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The DataView prototype object is the intrinsic object %DataViewPrototype%. The value of the [[Prototype]] internal slot of the DataView prototype object is the intrinsic object %ObjectPrototype% (19.1.3). The DataView prototype object is an ordinary object. It does not have a [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], or [[ByteOffset]] internal slot.
DataView.prototype.buffer
is an accessor property whose set accessor function is
undefined. Its get accessor function performs the following steps:
DataView
.prototype.byteLength
is an accessor property whose set accessor
function is undefined. Its get accessor function performs the following steps:
DataView
.prototype.byteOffset
is an accessor property whose set accessor
function is undefined. Its get accessor function performs the following steps:
The initial value of DataView.prototype.constructor
is the intrinsic object %DataView%.
When the getFloat32
method is called with argument byteOffset and optional
argument littleEndian the following steps are taken:
"Float32"
).When the getFloat64
method is called with argument byteOffset and optional
argument littleEndian the following steps are taken:
"Float64"
).When the getInt8
method is called with argument byteOffset the following
steps are taken:
"Int8"
).When the getInt16
method is called with argument byteOffset and optional
argument littleEndian the following steps are taken:
"Int16"
).When the getInt32
method is called with argument byteOffset and optional
argument littleEndian the following steps are taken:
"Int32"
).When the getUint8
method is called with argument byteOffset the following
steps are taken:
"Uint8"
).When the getUint16
method is called with argument byteOffset and optional
argument littleEndian the following steps are taken:
"Uint16"
).When the getUint32
method is called with argument byteOffset and optional
argument littleEndian the following steps are taken:
"Uint32"
).When the setFloat32
method is called with arguments byteOffset and
value and optional argument littleEndian the following steps are taken:
"Float32"
, value).When the setFloat64
method is called with arguments byteOffset and
value and optional argument littleEndian the following steps are taken:
"Float64"
, value).When the setInt8
method is called with arguments byteOffset and
value the following steps are taken:
"Int8"
,
value).When the setInt16
method is called with arguments byteOffset and
value and optional argument littleEndian the following steps are taken:
"Int16"
, value).When the setInt32
method is called with arguments byteOffset and
value and optional argument littleEndian the following steps are taken:
"Int32"
, value).When the setUint8
method is called with arguments byteOffset and
value the following steps are taken:
"Uint8"
,
value).When the setUint16
method is called with arguments byteOffset and
value and optional argument littleEndian the following steps are taken:
"Uint16"
, value).When the setUint32
method is called with arguments byteOffset and
value and optional argument littleEndian the following steps are taken:
"Uint32"
, value).The initial value of the @@toStringTag property is the String value "DataView"
.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
DataView instances are ordinary objects that inherit properties from the DataView prototype object. DataView instances each have [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], and [[ByteOffset]] internal slots.
NOTE The value of the [[DataView]] internal slot is not used within this specification. The simple
presence of that internal slot is used within the
specification to identify objects created using the DataView
constructor.
The JSON object is the %JSON% intrinsic object and the initial value of the JSON
property of the global
object. The JSON object is a single ordinary object that contains two functions, parse and stringify, that are
used to parse and construct JSON texts. The JSON Data Interchange Format is defined in ECMA-404. The JSON interchange format
used in this specification is exactly that described by ECMA-404.
Conforming implementations of JSON.parse
and JSON.stringify
must support the exact interchange format described in the ECMA-404
specification without any deletions or extensions to the format.
The value of the [[Prototype]] internal slot of the JSON object is the intrinsic object %ObjectPrototype% (19.1.3). The value of the [[Extensible]] internal slot of the JSON object is set to true.
The JSON object does not have a [[Construct]] internal method; it is not possible to use the JSON object as a constructor
with the new
operator.
The JSON object does not have a [[Call]] internal method; it is not possible to invoke the JSON object as a function.
The parse
function parses a JSON text (a JSON-formatted String) and produces an ECMAScript value. The JSON
format is a subset of the syntax for ECMAScript literals, Array Initializers and Object Initializers. After parsing, JSON
objects are realized as ECMAScript objects. JSON arrays are realized as ECMAScript Array instances. JSON strings, numbers,
booleans, and null are realized as ECMAScript Strings, Numbers, Booleans, and null.
The optional reviver parameter is a function that takes two parameters, key and value. It can filter and transform the results. It is called with each of the key/value pairs produced by the parse, and its return value is used instead of the original value. If it returns what it received, the structure is not modified. If it returns undefined then the property is deleted from the result.
"("
, JText, and ");"
.JSON allows Unicode code units 0x2028 (LINE SEPARATOR) and 0x2029 (PARAGRAPH SEPARATOR) to directly appear in String literals without using an escape sequence. This is enabled by using the following alternative definition of DoubleStringCharacter when parsing scriptText in step 5:
"
or \
or U+0000 through U+001F\
EscapeSequenceThe SV of DoubleStringCharacter :: SourceCharacter but not one of "
or \
or U+0000 through U+001F
is the UTF16Encoding (10.1.1) of the code point
value of SourceCharacter.
NOTE The syntax of a valid JSON text is a subset of the ECMAScript PrimaryExpression syntax. Hence a valid JSON text is also a valid PrimaryExpression. Step 3 above verifies that JText conforms to that subset. When scriptText is parsed and evaluated as a Script the result will be either a String, Number, Boolean, or Null primitive value or an Object defined as if by an ArrayLiteral or ObjectLiteral.
The abstract operation InternalizeJSONProperty is a recursive abstract operation that takes two parameters: a holder object and the String name of a property in that object. InternalizeJSONProperty uses the value of reviver that was originally passed to the above parse function.
"length"
)).It is not permitted for a conforming implementation of JSON.parse
to extend
the JSON grammars. If an implementation wishes to support a modified or extended JSON interchange format it must do so by
defining a different parse function.
NOTE In the case where there are duplicate name Strings within an object, lexically preceding values for the same key shall be overwritten.
The stringify
function returns a String in UTF-16 encoded JSON format representing an ECMAScript value. It
can take three parameters. The value parameter is an ECMAScript value, which is usually an object or array,
although it can also be a String, Boolean, Number or null. The optional replacer parameter is either a
function that alters the way objects and arrays are stringified, or an array of Strings and Numbers that acts as a white
list for selecting the object properties that will be stringified. The optional space parameter is a String or
Number that allows the result to have white space injected into it to improve human readability.
These are the steps in stringifying an object:
"length"
)).NOTE 1 JSON structures are allowed to be nested to any depth, but they must be acyclic. If value is or contains a cyclic structure, then the stringify function must throw a TypeError exception. This is an example of a value that cannot be stringified:
a = [];
a[0] = a;
my_text = JSON.stringify(a); // This must throw a TypeError.
NOTE 2 Symbolic primitive values are rendered as follows:
null
.true
.false
.NOTE 3 String values are wrapped in QUOTATION MARK ("
) code units. The code
units "
and \
are escaped with \
prefixes. Control characters code units are
replaced with escape sequences \u
HHHH, or with the shorter forms, \b
(BACKSPACE),
\f
(FORM FEED), \n
(LINE FEED), \r
(CARRIAGE RETURN), \t
(CHARACTER
TABULATION).
NOTE 4 Finite numbers are stringified as if by calling ToString(number). NaN and Infinity regardless of sign are
represented as the String null
.
NOTE 5 Values that do not have a JSON representation (such as undefined and functions)
do not produce a String. Instead they produce the undefined value. In arrays these values are
represented as the String null
. In objects an unrepresentable value causes the property to be excluded from
stringification.
NOTE 6 An object is rendered as U+007B (LEFT CURLY BRACKET) followed by zero or more properties, separated with a U+002C (COMMA), closed with a U+007D (RIGHT CURLY BRACKET). A property is a quoted String representing the key or property name, a U+003A (COLON), and then the stringified property value. An array is rendered as an opening U+005B (LEFT SQUARE BRACKET followed by zero or more values, separated with a U+002C (COMMA), closed with a U+005D (RIGHT SQUARE BRACKET).
The abstract operation SerializeJSONProperty with arguments key, and holder has access to ReplacerFunction
from the invocation of the stringify
method. Its algorithm is as follows:
"toJSON"
)."null"
."true"
."false"
."null"
.The abstract operation QuoteJSONString with argument value wraps a String value in QUOTATION MARK code units and escapes certain other code units within it.
BACKSPACE | "b" |
FORM FEED (FF) | "f" |
LINE FEED (LF) | "n" |
CARRIAGE RETURN (CR) | "r" |
LINE TABULATION | "t" |
"u"
.The abstract operation SerializeJSONObject with argument value serializes an object. It
has access to the stack, indent, gap, and PropertyList values of
the current invocation of the stringify
method.
":"
."{}"
."{"
, properties, and
"}"
."{"
, code unit 0x000A (LINE FEED),
indent, properties, code unit 0x000A, stepback, and "}"
.The abstract operation SerializeJSONArray with argument value serializes an array. It
has access to the stack, indent, and gap values of the current invocation of the
stringify
method.
"length"
))."null"
to partial."[]"
."["
, properties, and
"]"
."["
, code unit 0x000A (LINE FEED),
indent, properties, code unit 0x000A, stepback, and "]"
.NOTE The representation of arrays includes only the elements between zero and
array.length
– 1 inclusive. Properties whose keys
are not array indexes are excluded from the stringification. An array is stringified as an opening LEFT SQUARE BRACKET,
elements separated by COMMA, and a closing RIGHT SQUARE BRACKET.
The initial value of the @@toStringTag property is the String value "JSON"
.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.