summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2012-07-02 22:26:00 -0500
committerKamil Kaminski <kyle@kkaminsk.com>2012-07-02 22:26:00 -0500
commit0b2942ec56f8015c41a82937a07680028060a0e7 (patch)
treef26932c8d2dcc840492d68f658550d93b158dd05 /samples
parent46230d8dd0709829859dc1feb92db17933000fcc (diff)
downloadfubar-0b2942ec56f8015c41a82937a07680028060a0e7.tar.gz
fubar-0b2942ec56f8015c41a82937a07680028060a0e7.tar.bz2
fubar-0b2942ec56f8015c41a82937a07680028060a0e7.zip
learn on events, tweak html
Diffstat (limited to 'samples')
-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();
+