summaryrefslogtreecommitdiffstats
path: root/samples/ref_to_instance.js
blob: 975756f5a327b03e560d9eb7b6195f3cfddfc413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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();