Can you help me to understand ES6 and Object ?
class Contact{
constructor(name,tel,mail)
this.name=name;
this.tel=tel;
this.mail=mail;
method1(){
//code
}
}
If I want create a contact I can use
const me = new Contact('David','070809112','10 street of Paris')
But I'm not able to use Object.create() before ES6 I can use Object.create() with ES6 Ican't can you help me ?
BEFORE ES6
var Contact ={
init:function('name','tel','mail')
this.name=name;
this.tel=tel;
this.mail=mail;
method1 : function(){
//code
}
}
var me = Object.create(Contact);
me.init('David','070809112','10 street of Paris');
In this case How use Object.create() ? for create a new contact. Thanks
Object.create(Contact)in ES6 whereContactis defined as a class?initmethod which is called separately: this you can also do with ES6classandObject.create. The thing is that you introduce aconstructorin the ES6 example, which for some reason you did not choose to use in the ES5 code. So the comparison really does not work.