I am programming in JavaScript and I created an array called users and a constructor for the user object. Everytime a new object is created I want to add it to the array.
var users = [];
function user(username, password){
this.username = username;
this.password = password;
users[users.length-1] = this;
};
var joe = new user('Joe', "joe100");
The way above doesn't seem to work. How can I add an object to an array in the constructor?
-1