mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
LibJS: Add ArrayPrototype and implement Array.prototype.push()
This function is ultimately supposed to be generic and allow any |this| that has a length property, but for now it only works on our own Array object type.
This commit is contained in:
parent
8f7d4f67a4
commit
bceabd7c4b
9 changed files with 110 additions and 4 deletions
|
@ -25,12 +25,14 @@
|
|||
*/
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
Array::Array()
|
||||
{
|
||||
set_prototype(interpreter().array_prototype());
|
||||
put_native_property(
|
||||
"length",
|
||||
[this](Object*) {
|
||||
|
@ -45,7 +47,7 @@ Array::~Array()
|
|||
{
|
||||
}
|
||||
|
||||
void Array::append(Value value)
|
||||
void Array::push(Value value)
|
||||
{
|
||||
m_elements.append(value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue