35 lines
455 B
JavaScript
35 lines
455 B
JavaScript
/*
|
|
* Unexpected things happen here...
|
|
*/
|
|
|
|
function a() {}
|
|
|
|
b = function() {}
|
|
|
|
// Notice the weird behavior :
|
|
|
|
typeof a; // object
|
|
typeof b; // function
|
|
|
|
aclass = function () {
|
|
this.setFoo(1);
|
|
return this;
|
|
}
|
|
|
|
typeof aclass;
|
|
|
|
aclass.prototype.setFoo = function (v) {
|
|
this.foo = v;
|
|
}
|
|
|
|
anObject = new aclass() ;
|
|
|
|
anObject.setFoo(2);
|
|
|
|
anObject.foo;
|
|
|
|
// Also worth mentionning, you ***must*** use new and this doesn't work :
|
|
//
|
|
// anobject = aclass();
|
|
|