gpt4 book ai didi

javascript - 含义 var lineColor = { red : 'blue' , blue: 'red' }[lineColor];

转载 作者:行者123 更新时间:2023-11-28 19:08:32 28 4
gpt4 key购买 nike

 $('#toggle-linecolor').click(function () {
chart.yAxis[0].update({
lineColor: lineColor
});
lineColor = { red: 'blue', blue: 'red' }[lineColor];
});

最佳答案

它在'red''blue'之间切换。

假设您开始于:

var lineColor = 'red';

执行此操作会将lineColor更改为“蓝色”

lineColor = { red: 'blue', blue: 'red' }[lineColor];
// The property [red] of that object has a value of 'blue'

lineColor // <--- 'blue'

再次执行它,会将值切换为“红色”

lineColor = { red: 'blue', blue: 'red' }[lineColor];
// The property [blue] of that object has a value of 'red'

lineColor // <---- 'red'

关于javascript - 含义 var lineColor = { red : 'blue' , blue: 'red' }[lineColor];,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31181444/

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