1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 esid: sec-%typedarray%.prototype.tolocalestring
5 description: Returns a string
7 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
9 %TypedArray%.prototype.toLocaleString is a distinct function that implements
10 the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
11 except that the this object's [[ArrayLength]] internal slot is accessed in
12 place of performing a [[Get]] of "length".
14 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
17 5. Let firstElement be ? Get(array, "0").
18 6. If firstElement is undefined or null, then
19 a. Let R be the empty String.
21 a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
23 9.Repeat, while k < len
24 a. Let S be a String value produced by concatenating R and separator.
25 b. Let nextElement be ? Get(array, ! ToString(k)).
26 c. If nextElement is undefined or null, then
27 i. Let R be the empty String.
29 i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
30 includes: [testTypedArray.js]
31 features: [TypedArray]
34 var separator = ["", ""].toLocaleString();
36 var arr = [42, 0, 43];
38 testWithTypedArrayConstructors(function(TA, N) {
39 var sample = new TA(arr);
41 sample[0].toLocaleString().toString() +
43 sample[1].toLocaleString().toString() +
45 sample[2].toLocaleString().toString();
46 assert.sameValue(sample.toLocaleString(), expected);