oop - creating numbered objects from a constructor in javascript -


i have constructor makes squares.

i code automatically create squares constructor using loops , name them square1, square2, square3 ect.

eg.

for (n=1; n < x; n++){ var square(n) = new square(); } 

is possible?

if how , how refer them in loop - square(n)?

i'm new programming, oop , javascript sorry if ovb. in advance

that's arrays for:

var squares = new array(); (var n = 1; n < x; n++) {     squares.push( new square() ); } 

now you're able access them zero-based index:

squares[0].somemethod(); // etc.. 

to iterate on squares in array:

for (var = 0; < squares.length; i++) {     squares[i].somemethod(); } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -