Greasemonkey and JavaScript 1.7

23 views
Skip to first unread message

BlindWanderer

unread,
Jul 6, 2007, 1:38:57 AM7/6/07
to greasemonkey-dev
It would be great if the new features of JavaScript 1.7 could be
leveraged in userscripts. JavaScript 1.7 is in Firefox 2.0 (and 1.8 is
in of 3.0) and provides a couple new keywords that have some
advantages, they are: 'let' and 'yield'. While I am not sure about the
usefulness (or the sanity) of 'yield', 'let' is without a doubt
useful. Take for example with GM_xmlhttpRequest described at:
http://wiki.greasespot.net/Troubleshooting

It can be simplified to something like below, When it runs it will
output "f","f","f","f","f","f".

links = ["a", "b", "c", "d", "e", "f"];
for (var i=0; i < links.length; i++) {
var link = links[i];
window.setTimeout(function (){console.log(link);}, 0);
}

Now if we use the let keyword side by side we get... ["f","a"],
["f","b"],["f","c"],["f","d"],["f","e"],["f","f"].
links = ["a", "b", "c", "d", "e", "f"];
for (var i=0; i < links.length; i++) {
var link = links[i];
let linked = links[i];
window.setTimeout(function (){console.log([link,linked]);}, 0);
}

As you can see, the advantages are valid. So why haven't I posted a
patch? I can't figure out how to get it enabled. Components are auto-
loaded and JSVersion is inherited from the parent. If there is a
workaround (that doesn't compromise security) I can't find it. Anyone
have any ideas?

http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7
http://developer.mozilla.org/en/docs/New_in_JavaScript_1.8

Reply all
Reply to author
Forward
0 new messages