+ 1
How to Create a method inside A method in javascript ?
I have a Javascript class "Command" , in this class I have two methods/functions I) contructor II) show. I want to create a method inside show , "previous" that returns a value x. I want to access this like.... var cmd = new Command; cmd.show().previous() , how can I do that ?
5 Answers
+ 4
this is how to do it
class cmd {
show() {
return {
previous: () => {
...
};
}
}
};
+ 2
Something like this?
function func() {
alert("hello")
func.display = function() {
alert("world")
};
}
func()
func.display()
+ 2
NimaPoshtiban thank you so much for your help
+ 2
rkk thanks you
0
rkk I want to create a function inside fun.display