I have property yaCounter27352058 in window object.
I can easily get it using bracket notation
window["yaCounter27352058"]
The problem is that I don't know object id, so in general I want to get all objects like this
window["yaCounter*"]
Well, in fact you can't. But you can do something else.
You can try to list all your properties with
var properties = Object.keys(window).
Then with a regexp you will select your properties starting with yaCounter :
var reg = new RegExp("^yaCounter.*");
var goodProp = [];
properties.forEach(function(prop) {
if (reg.exec(prop) != null)
goodProp.push(prop);
}
And them use these with :
goodProp.forEach(function(val) {
window[val];
}));
exec only takes a string, so this would only match if the yaCounter variable was the first property on window which it's unlikely to be...