0

[javascript] Syntax for adding method to retrieve properties from that class?

Please help with example.

6th Dec 2017, 7:38 AM
Joe
Joe - avatar
4 Respuestas
+ 2
Properties of HTML class attribute or OOP class?
6th Dec 2017, 9:15 AM
Calviղ
Calviղ - avatar
+ 2
Answer about constructor function already here,so Ill add class one... class User { constructor (name){ this.name = name } logName() { console.log(this.name) } } let Alex = new User(Alex) Alex.logName() //Alex
7th Dec 2017, 9:33 PM
Rose Sevenyears
Rose  Sevenyears - avatar
+ 1
// Possibly you are asking about method constructor function Name( age ){ this.age = age; // A class method this.dob = function(){ return 2017 - this.age; } } var person = new Name; // dob for Date of Birth alert(person.dob(17)); // Alerts 2000;
6th Dec 2017, 8:18 AM
#RahulVerma
#RahulVerma - avatar
+ 1
properties of OOP class
7th Dec 2017, 3:39 AM
Joe
Joe - avatar