If i have a function defined inside some object as in :
var myobject={
myfunction:function(){//mycode here}
}
usually you can access the function using:
myobject.myfunction()
but what if i want to use
myobject["myfunction"]
trying so , actually the function did not get called , how can i call the function using brackets notation ?
Use it like. You were very close
myobject["myfunction"]();
You can also do this
var myfuncname="myfunction";
myobject[myfuncname]();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With