Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
变量 v; v = (v || 0) + 3;
在学习 javascript 时,我遇到了这个问题。有谁知道它是如何工作的,它叫什么等等。
如果这两个陈述都紧随其后,那么它没有多大意义..它只是意味着这个
var v; //which is undefined here if(!v) //which is true in this case.. { v=0; //initialize v=0; } v +=3; //Now increment v here as if it doesn't know what v was.
猜猜这组语句总是输出3是什么。
只需将其替换为var v=3:)
var v=3