以下是代码:
function BinarySearchNode(key) {
let node = {};
node.key = key;
node.lft = null;
node.rgt = null;
node.log = () => {
console.log(node.key);
}
node.get_node_with_parent = (key) => {
let parent = null;
while (this) {
if (key == this.key) {
return [this, parent];
}
if (key < this.key) {
[this, parent] = [this.lft, this];
} else {
[this, parent] = [this.rgt, this];
}
}
return [null, parent];
}
return node;
}
我的Firefox为44.0
,它会为这些行抛出SyntaxError
:
if (key < this.key) {
[this, parent] = [this.lft, this];
} else {
我试着通过阅读this blogpost和the MDN来了解这里到底出了什么问题。不幸的是,我仍然想念它:(