mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Make 'this' a keyword (now faster, more memory efficient)
Make 'Hardware' (root) the default value of 'this'
14 lines
303 B
JavaScript
14 lines
303 B
JavaScript
// See https://github.com/espruino/Espruino/issues/109
|
|
var a = { hi : "Hello", b : function() { return this.hi; } };
|
|
|
|
function run(cb) { return cb(); }
|
|
var c = a.b;
|
|
|
|
var res = [
|
|
a.b(),
|
|
run(a.b),
|
|
c(),
|
|
run(c) ];
|
|
|
|
result = res[0]=="Hello" && res[1]===undefined && res[2]===undefined && res[3]===undefined;
|