diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-28 16:56:54 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-28 16:56:54 +0100 |
commit | a3d92b1210bad42a7563b6a7d9a8787d6d2586ed (patch) | |
tree | 81e9ccca06853492b4cc8ddd20ba85b555288b8f /Libraries/LibJS/Tests/instanceof-basic.js | |
parent | 37fe16a99cd9ce31d6dba0b916be67929ae010a3 (diff) | |
download | serenity-a3d92b1210bad42a7563b6a7d9a8787d6d2586ed.zip |
LibJS: Implement the "instanceof" operator
This operator walks the prototype chain of the RHS value and looks for
a "prototype" property with the same value as the prototype of the LHS.
This is pretty cool. :^)
Diffstat (limited to 'Libraries/LibJS/Tests/instanceof-basic.js')
-rw-r--r-- | Libraries/LibJS/Tests/instanceof-basic.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/instanceof-basic.js b/Libraries/LibJS/Tests/instanceof-basic.js new file mode 100644 index 0000000000..468da2f7fd --- /dev/null +++ b/Libraries/LibJS/Tests/instanceof-basic.js @@ -0,0 +1,7 @@ +function Foo() { + this.x = 123; +} + +var foo = new Foo(); +if (foo instanceof Foo) + console.log("PASS"); |