I write a linked list,when I use multiple assignment ,the result is strange。What's the different between python and javascript?
The sample python code
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
node=ListNode(0)
node=node.next=ListNode(10)
#expect node.next=ListNode(10) node=node.next
print(node ==node.next) # True why?
The same logic JavaScript code
function ListNode(val){
this.val=val;
this.next=null;
}
var node=new ListNode(0);
node=node.next=new ListNode(10)
console.log(node==node.next) //false