mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-20 05:40:17 +08:00
* 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
20 lines
708 B
JavaScript
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(','));
|