gpt4 book ai didi

JavaScript a=b=c 语句

转载 作者:行者123 更新时间:2023-12-02 22:26:47 25 4
gpt4 key购买 nike

我在互联网上进行了搜索,但找不到相关的搜索条件,所以我认为这是最好的提问地点。

我有一个 JS 语句说

document.location.hash = this.slug = this.sliceHashFromHref(href)

这是如何工作的?

最佳答案

How does this work??

a = b 既可以看作语句,也可以看作表达式

表达式的结果是b

换句话说,

a = b = c;

可以写成

a = (b = c);

相当于

b = c;
a = b;

因此您的代码相当于:

this.slug = this.sliceHashFromHref(href);
document.location.hash = this.slug;

关于JavaScript a=b=c 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7511279/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com