oop - Javascript pushing object into array -


hey, having trouble trying work. here's sample code of trying. lot has been taken out, should still contain problem. have object, user, , array, player. trying make array players in it, here:

function user(name, level, job, apparel) {  this.name = name;  this.state = "alive";  this.level = level;  this.job = job;  this.apparel = apparel; }  player = new array(); player.push(new user("main player", 1, 1, "naked")); document.write(player[0].name); 

but it's not working, nothing's being echo'd. doing wrong?

i

player = []; 

instead of

player = new array(); 

as sanity check, try doing:

document.write("name: " + player[0].name); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -