gpt4 book ai didi

javascript - 在 JavaScript 中定义变量

转载 作者:行者123 更新时间:2023-11-28 21:25:56 25 4
gpt4 key购买 nike

我的 JavaScript 函数中有很多变量,不适合一行声明。

var query_string = $('list_form').serialize(), container = $('list_container'),position = container.cumulativeOffset(), layer = $('loaderLayer'),
remote_url = "/web/view/list_offers.php?" + query_string;

有没有一种方法可以只用一行在多行上定义这些变量

var

关键字?

最佳答案

var query_string = $('list_form').serialize(),
container = $('list_container'),
position = container.cumulativeOffset(),
layer = $('loaderLayer'),
remote_url = "/web/view/list_offers.php?" + query_string;

如果我没记错的话,这是 Doughlas Crackford 提倡的声明脚本需要的多个变量的模式。

快速提示: Beawere of JavaScript Hoisting :)

关于javascript - 在 JavaScript 中定义变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5040097/

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