Below I have tested the new features in JavaScript 1.8. The code below is also run immediately as you load the page, so you will see the actual results as well. Below each test is the web browsers it works in, and the minimum version of it required.
More information about JavaScript 1.8
// Notice the omission of braces and return statement function expressionClosure () "Yeah, ok"
Result: FAILED
3.0+
var animals = {
dog : "Nice",
cat : "Independent",
horse : "big"
},
resultValues = [],
iterating = (i + 3 for (i in animals));
try {
while (true) {
resultValues.push(iterating.next());
}
}
catch (err if err instanceof StopIteration) {
resultValues.push("END OF LIST");
}
Result: FAILED
3.0+
var numbers = [1, 2, 3, 4, 5],
returnValues = [];
numbers.reduce(function (prev, current, index, array) {
returnValues.push("Previous: " + prev + ", current: " + current + ", index: " + index);
return current;
});
Result: FAILED
3.0+
4.0+
4.0+
var numbers = [1, 2, 3, 4, 5],
returnValues = [];
numbers.reduceRight(function (prev, current, index, array) {
returnValues.push("Previous: " + prev + ", current: " + current + ", index: " + index);
return current;
});
Result: FAILED
3.0+
4.0+
4.0+