Files
scriptc/tests/corpus/native-array-length.js
Chris Tate f8906d0b75 Expand static native object and array semantics (#569)
* Support primitive and function property descriptors

* Dispatch literal bracket calls to native class methods

* Handle numeric class method keys in bracket calls

* Call function values returned by class accessors

* Expand native object and array semantics

* Keep new corpus fixtures aligned with compiler gates

* Lower Object.isFrozen arguments once
2026-09-29 08:30:54 -05:00

20 lines
708 B
JavaScript

const values = JSON.parse('[1,2,3,4]');
values.length = 2;
console.log(values.length, values.join(','), Object.keys(values).join(','));
values.length = 2;
console.log(values.length, Object.hasOwn(values, '2'));
values[2] = 8;
console.log(values.join(','));
try { values.length = -1; } catch (error) { console.log(error.name); }
console.log(values.length);
const sealed = JSON.parse('[1,2,3]');
Object.seal(sealed);
try { sealed.length = 1; } catch (error) { console.log(error.name); }
console.log(sealed.length, sealed.join(','));
const frozen = JSON.parse('[1,2]');
Object.freeze(frozen);
try { frozen.length = 1; } catch (error) { console.log(error.name); }
console.log(frozen.length, frozen.join(','));