1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 03:15:08 +00:00

LibJS: Add StringPrototype and make it the prototype of StringObject

This patch adds String.prototype.charAt() to demonstrate that prototype
property lookup works, and that you can call a prototype function on an
object, and it will do what you expect. :^)
This commit is contained in:
Andreas Kling 2020-03-15 15:02:49 +01:00
parent f7c15d00c9
commit 2c5b9fb8f9
6 changed files with 109 additions and 0 deletions

View file

@ -37,8 +37,12 @@ public:
virtual void visit_children(Visitor&) override;
const PrimitiveString* primitive_string() const { return m_string; }
private:
virtual const char* class_name() const override { return "StringObject"; }
virtual bool is_string_object() const override { return true; }
PrimitiveString* m_string { nullptr };
};