There are several ways to return multiple values in JavaScript. You've always been able to return multiple values in an array:
function f() {
return [1, 2];
}
And access them like this:
var ret = f();
document.write(ret[0]); // first return value
But the syntax is much nicer in JavaScript 1.7 with the addition of destructuring assignment (if you're lucky enough to be targeting an environment guaranteed to support it (e.g. a Firefox extension)):
var a, b;
[a, b] = f();
document.write("a is " + a + " b is " + b + "<br>\n");
Another option is to return an object literal containing your values:
function f() {
return { one: 1, two: 2 };
}
Which can then be accessed by name:
var ret = f();
document.write(ret.one + ", " + ret.two);
And of course you could do something really horrible like modify global scope or even set properties on the function itself:
function f() {
f.one = 1;
f.two = 2;
}
f();
document.write(f.one + ", " + f.two);
More reading (and the source of some of these examples):
https://developer.mozilla.org/en/New_in_JavaScript_1.7#Destructuring_assignment_(Merge_into_own_page.2fsection)