Transcrypt
Transcrypt copied to clipboard
error comparing array and tuples
Python:
def compare():
x = [1,2]
y = [1,2]
console.log(f"array: {x!r} == {y!r} => {x == y}")
x2 = (1,2)
y2 = (1,2)
console.log(f"tuple: {x2!r} == {y2!r} => {x2 == y2}")
generated javascript:
export var compare = function () {
var x = [1, 2];
var y = [1, 2];
console.log ('array: {} == {} => {}'.format (x, y, x == y));
var x2 = tuple ([1, 2]);
var y2 = tuple ([1, 2]);
console.log ('tuple: {} == {} => {}'.format (x2, y2, x2 == y2));
};
Console output:
array: [1, 2] == [1, 2] => False
tuple: (1, 2) == (1, 2) => False
It seems arrays can't be compared that way in JavaScript: https://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript