ilhan
ilhan

Reputation: 8963

How to create dynamic variable names for ExtJS objects?

I am trying to create

window1 = Ext.create('Ext.window.Window', {

then

window2 = Ext.create('Ext.window.Window', {

and so on

I want them to be created in the for loop that I already have but the standart dynamic variable names for JavaScript didn't work, probably because it wants me to write new or may be something to do with global scope, I don't know.

Upvotes: 0

Views: 494

Answers (1)

Emissary
Emissary

Reputation: 10148

It's not really clear what you are asking, what's wrong with:

var myWindows = {};
for(var i=0; i<10; i++)
    myWindows['win'+i] = Ext.create('Ext.Window', { /* ... */ });
console.log( myWindows.win1 === myWindows['win'+1] ) // true

see: Object Access Notation

Upvotes: 1

Related Questions