我创建了一个弹出窗口。我想打开三遍。并非一直如此
xyz@gmail.com
答案 0 :(得分:0)
// make falsy (null, undefined, empty string) = 0
var walk_in = localStorage.getItem('walk_in') || 0;
walk_in++; // cast to number and increment
if (walk_in<=3) {
$.getJson( ....
if (result.country == 'IN') {
localStorage.setItem('walk_in', walk_in);
测试stringVar++
:
var counter = ""
console.log(counter,typeof counter)
counter = counter || 0
console.log(counter,typeof counter)
counter = "1"
console.log(counter,typeof counter)
counter = counter || 0
counter++; // casts and adds
console.log(counter,typeof counter)