summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/constructor-basic.js
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-28 16:33:52 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-28 16:33:52 +0100
commit0593ce406b588e5bf76440bdf56eeb04bbe12ec9 (patch)
treeb1c5bdaa3332acc6c6d390cf06b7b9334d2d3ef0 /Libraries/LibJS/Tests/constructor-basic.js
parentfecbef4ffe907ff160c0570b134fb87102f1194f (diff)
downloadserenity-0593ce406b588e5bf76440bdf56eeb04bbe12ec9.zip
LibJS: Implement basic support for the "new" keyword
NewExpression mostly piggybacks on the existing CallExpression. The big difference is that "new" creates a new Object and passes it as |this| to the callee.
Diffstat (limited to 'Libraries/LibJS/Tests/constructor-basic.js')
-rw-r--r--Libraries/LibJS/Tests/constructor-basic.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/constructor-basic.js b/Libraries/LibJS/Tests/constructor-basic.js
new file mode 100644
index 0000000000..9e2e1233ea
--- /dev/null
+++ b/Libraries/LibJS/Tests/constructor-basic.js
@@ -0,0 +1,7 @@
+function Foo() {
+ this.x = 123;
+}
+
+var foo = new Foo();
+if (foo.x === 123)
+ console.log("PASS");