i have showProfile function which is accept callback function .
The callback function has also an argment which is an object.
showProfile(call_back_fn)
invoke it :
showProfile(function(obj){console.log(obj)})
I want to set this function as an attribute to Person Object :
function Person(name,age,showProfile){
this.name=name ;
this.age=age;
/*
this.showProfile=showProfile ???
OR
this.prototype.showProfile=showProfile ???
OR What ??
*/
return this;
}
then ,to create a Person object :
var p=new Person('Abdennour',23,fnshowProfile);
How can i make this function(showProfile) as an object attribute .and if it's possible , how to pass its argument(wich is a call back function) ?
Then , How to Call fnshowProfile
which is in the snippet above.
UPDATE
OtherWise, if i create a Person object as follwoing :
var p=new Person('Abdennour',23,showProfile());
How can i access to showProfile to add a callback function as argument:
an d then , how can i execute showProfile from p
object.