1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

LibJS: Add basic Array constructor

We only support Array() with 0 or 1 parameters so far.
This commit is contained in:
Andreas Kling 2020-04-04 22:28:21 +02:00
parent eabdbe0ee9
commit d155491122
6 changed files with 132 additions and 0 deletions

View file

@ -0,0 +1,16 @@
function assert(x) { if (!x) throw 1; }
try {
assert(Array.length === 1);
assert(Array.prototype.length === 0);
assert(typeof Array() === "object");
assert(typeof new Array() === "object");
x = new Array(5);
assert(x.length === 5);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}