Hello,
I'm quite surprised to see comon javascript function not working : Array.filter, Array.forEach, …
What is the java(ecma) script version used in oolite ? The wiki does not specify it.
javascript version
Moderators: winston, another_commander
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
Re: javascript version
Thanks for your answer, I was getting crazy with this !
I was used to call filter, forEach with this syntax :
which seems works fine in a browser, but does not work in oolite.
And inded the filter, forEach require actualy a callback function with arity 3 : element, index, and a reference to the array. This code exemple works :
I was used to call filter, forEach with this syntax :
Code: Select all
arr.filter(function(item) {
return …;
});
And inded the filter, forEach require actualy a callback function with arity 3 : element, index, and a reference to the array. This code exemple works :
Code: Select all
var stations = system.stations.filter( function(el, idx, arr) {
player.consoleMessage("Found the station " + el.name + "(" + idx + ")");
return el.allegiance === "neutral" || el.allegiance === "galcop" || el.allegiance === "chaotic";
});