JS constructor would be more useful.
function User(username, password, email) { this.username = username this.password = password this.email = email this.isActive = function() { return (this.password ? "Y" : "N"); } }
Then you can assign it as much as you want:
var student1 = new User('alex', 'p@ssw0rd', 'alex@example.com') var student2 = new User('john', 'kRypt0n', 'john@example.com') student1.isActive()
And you can change property value on the fly:
student1.password = 'myNewP@$$w0rd'
It's even more slick with ES6 classes:
class User { constructor (username, password, email) { this.username = username; this.password = password; this.email = email; } isActive () { return Boolean(this.password); } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
JS constructor would be more useful.
Then you can assign it as much as you want:
And you can change property value on the fly:
It's even more slick with ES6 classes: