Reputation: 95
I would like to know if this is possible:
I want to access a index of an object that point for another index in the same object..
example:
var object = {
edit: function (string) {
alert(string);
},
edit2: "call default edit()"
};
object.edit2("Hello World!!");
How can I do that?
Sorry my english is.. bad
Upvotes: 0
Views: 58
Reputation: 7416
You could just do it like this
var object = {
edit : function(string){
alert(string);
},
edit2 :function(string){
this.edit(string);
}
};
object.edit2("Hello World!!");
Upvotes: 3
Reputation: 1090
I think Javascript allow:
var object = {edit : function(string){alert(string)} };
object.edit2 = object.edit;
object.edit2("Hello World!!")
or scrblnrd3's solution.
This website is international, so i guess you're not the only one who don't speak very well english... (Why are you looking at me ?)
Upvotes: 0
Reputation: 1547
How about this:
var object = {edit : function(string){alert(string)},
edit2 : function(string){this.edit(string)}
}
object.edit2("Hello World!!")
Upvotes: 1