Espruino/tests/test_using_this_in_callback_functions.js
Michael Duerinckx 7f5308590b Rename numbered tests to something more descriptive - closes #16
test077 is the only one I really couldn't figure out what it was meant
to test.
2014-03-01 22:15:28 +00:00

10 lines
390 B
JavaScript

// using 'this' in callback
// Heavily modified now, so it actually works like proper JavaScript
result = 0;
function A() { }
A.prototype.set = function() { console.log("set"); };
function unset() { console.log("unset"); };
A.prototype.foo = function() { console.log(this); this.set(); setTimeout(function() { console.log(this); this.unset(); result=1; }, 10); };
var a = new A();
a.foo()