Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 这段代码需要解释吗?_Javascript - Fatal编程技术网

Javascript 这段代码需要解释吗?

Javascript 这段代码需要解释吗?,javascript,Javascript,这两条线的区别是什么 var p = this.getParams(); var pD = (o.params||{}); if (this.useJsonData) pD = (pD.jsonData||{}); this.cursor = (pD && pD[p.start]) ? pD[p.start] : 0; 第一个代码是否正常或有故障。您的第二行有故障。如果pD为空怎么办? 它还将保持this.cursor的值为true(即不是null或false) 否则,它们是相

这两条线的区别是什么

var p = this.getParams();
var pD = (o.params||{});
if (this.useJsonData) pD = (pD.jsonData||{});
this.cursor = (pD && pD[p.start]) ? pD[p.start] : 0;

第一个代码是否正常或有故障。

您的第二行有故障。如果pD为空怎么办? 它还将保持this.cursor的值为true(即不是null或false)

否则,它们是相同的。

请查看本页:


搜索
条件运算符
逻辑运算符
短路评估

好,不一定相同。第一个光标总是会更改。光标,但第二个光标可能会保持不变。是的。读两遍,评论一次。
this.cursor = pD[p.start] || this.cursor || 0;