From a3d92b1210bad42a7563b6a7d9a8787d6d2586ed Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 28 Mar 2020 16:56:54 +0100 Subject: 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. :^) --- Libraries/LibJS/Tests/instanceof-basic.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Libraries/LibJS/Tests/instanceof-basic.js (limited to 'Libraries/LibJS/Tests/instanceof-basic.js') 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"); -- cgit v1.2.3