我有以下JavaScript代码,我对这些行有一些疑问,
.events.slice (-1)[0][0]
是什么意思? nodes_params += "&ns=" + GLOBAL_EVENT + "," + start_from + ",-,-";
这一行也是?整个代码太大了,但我可以发布代码的一些部分,以防它不明白。
// Subscribe to the global events
var start_from = "0";
if (nodes[GLOBAL_EVENT].events && nodes[GLOBAL_EVENT].events.length > 0) {
start_from = nodes[GLOBAL_EVENT].events.slice(-1)[0][0];
}
nodes_params += "&ns=" + GLOBAL_EVENT + "," + start_from + ",-,-";
答案 0 :(得分:0)
1 - events
在数组上,events.slice(-1)
返回此数组中的最后一个元素,似乎是一个多维数组本身,[0] [0]返回第一个元素阵列。
2 - 它是一个简单的字符串连接,+ =意味着附加到现有变量而不是替换它
3 - 不能肯定地说,这取决于其他代码是什么