summaryrefslogtreecommitdiffstats
path: root/samples/ref_to_instance.js
diff options
context:
space:
mode:
Diffstat (limited to 'samples/ref_to_instance.js')
-rw-r--r--samples/ref_to_instance.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/samples/ref_to_instance.js b/samples/ref_to_instance.js
new file mode 100644
index 0000000..975756f
--- /dev/null
+++ b/samples/ref_to_instance.js
@@ -0,0 +1,17 @@
+function foo() {
+ if ((this instanceof foo) === false)
+ {
+ console.log('not an instance, hence a reference!');
+ /* returns new object of this class, which will trigger runtime of this
+ * function */
+ return new foo();
+ }
+ else
+ console.log('you have an instance?');
+}
+
+var ref = foo;
+ref.call(ref);
+
+var inst = new foo();
+