I don't see anything in the documentation that would indicate that the handling of arguments to functions is very different from that in Python, so the following looks like a serious bug in handling argument passing. This of course also affects passing arguments to __init__ of a class.
def f(a=[10,20], b=[30,40]):
console.log(a)
console.log(b)
f(b=[1,2],a=[3,4])
compiles to the following:
function f(a, b) {
if (typeof a === "undefined") a = [ 10, 20 ];
if (typeof b === "undefined") b = [ 30, 40 ];];
console.log(a); # Incorrect (should be [3,4]): Object {b: Array[2], a: Array[2]}
console.log(b); # Incorrect (should be [1,2]): [30, 40, append: function, ......
}
f({b: [ 1, 2 ], a: [ 3, 4 ]});
but it should compile to this:
function f(args) {
var a, b;
if (typeof args.a === "undefined") a = [ 10, 20 ];
else a = args.a;
if (typeof args.b === "undefined") b = [ 30, 40 ];
else b = args.b;
console.log(a); # Correct: [3, 4, append: function .....
console.log(b); # Correct: [1, 2, append: function .....
}
f({b: [ 1, 2 ], a: [ 3, 4 ]});