当我运行function
从窗口获取所有可用变量时...它只会正确显示非声明变量
宣布变量后:
var
let
const
代码中断......
怎么回事? 这可以解决吗?
抬头
我不想使用iframe ......
a = 'apple';
b = 'banana';
c = 'cherry';
d = /dog/gi;
e = 'elephant';
f = 'fish';
g = 'ground';
h = 'horse';
windowCounter = 0;
function Variables() {
for (let i in window) {
if (window.hasOwnProperty(i)) {
windowCounter++;
if (windowCounter > 165) {
console.log(i+' = '+window[i]);
}
}
};
}
Variables();
let a = 'apple';
const b = 'banana';
const c = 'cherry';
let d = /dog/gi;
var e = 'elephant';
f = 'fish';//This is the only one that works properly
let g = 'ground';
var h = 'horse';
windowCounter = 0;//And this one…
function Variables() {
for (let i in window) {
if (window.hasOwnProperty(i)) {
windowCounter++;
if (windowCounter > 165) {
console.log(i+' = '+window[i]);
}
}
};
}
Variables();