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
Jaak Kütt
2,6864 gold badges35 silver badges41 bronze badges
asked Jan 3, 2014 at 22:20
Jhonatan G.
951 gold badge3 silver badges11 bronze badges
-
What is "index of an object that point for another index in the same object"?dumbass– dumbass2024年12月26日 22:29:48 +00:00Commented Dec 26, 2024 at 22:29
3 Answers 3
You could just do it like this
var object = {
edit : function(string){
alert(string);
},
edit2 :function(string){
this.edit(string);
}
};
object.edit2("Hello World!!");
Blundering Philosopher
6,8492 gold badges46 silver badges63 bronze badges
answered Jan 3, 2014 at 22:23
scrblnrd3
7,4449 gold badges36 silver badges65 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Alex Shilman
Ahh, you beat me to it.
Jhonatan G.
Like ninjas - Thanksss XD
How about this:
var object = {edit : function(string){alert(string)},
edit2 : function(string){this.edit(string)}
}
object.edit2("Hello World!!")
answered Jan 3, 2014 at 22:24
Alex Shilman
1,5471 gold badge11 silver badges15 bronze badges
Comments
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 ?)
answered Jan 3, 2014 at 22:29
Loenix
1,1191 gold badge11 silver badges23 bronze badges
Comments
lang-js