function go(a, b){
console.log(a);
console.log(b);
}
go(b="happy", a="sad");
How can I make this work, just like it does in python?
Not really part of the language, but you can fake it like this: http://www.javascriptkit.com/javatutors/namedfunction.shtml
Example:
function go( params ) {
console.log(params.a);
console.log(params.b);
}
go( { b:"happy", a:"sad"} );
While there are some libraries which claim that they will let you do that (Prototype has a backwards way of making this possible), it is not cross browser compliant and it certainly isn't the the ECMAScript specification that JS is based off of.
The only way to have reliable behavior is to use the arguments in the order they were listed.