Testing JavaScript 1.8 - To index of all tests and compatibility tables

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

Expression closures

// Notice the omission of braces and return statement
function expressionClosure () "Yeah, ok"

Result: FAILED

Works in:

Generator expressions

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

Works in:

Array extras

reduce

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

Works in:

reduceRight

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

Works in: