When I run a function
to get all available variables from the window… it will only show non declared variables properly
Once variables have been declared:
var
let
const
Code breaks…
Whats going on?
Can this be fixed?
Heads up
I don't want to use iframe…
What works
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();
Problem
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();