ramblings/oxygen/js-debugger/test.js

35 lines
455 B
JavaScript
Raw Normal View History

2021-04-24 19:01:23 +00:00
/*
* Unexpected things happen here...
*/
function a() {}
b = function() {}
2021-04-24 19:01:23 +00:00
// 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;
2021-04-24 19:01:23 +00:00
// Also worth mentionning, you ***must*** use new and this doesn't work :
//
// anobject = aclass();