I have an issue, where I want to create a ‘hook’ in javascript, so I created a small function to do it.
Here is my code:
GoogleMaps.prototype.callUserFunc = function( func, args ){
eval('GoogleMaps.' + func + '.apply(func, args)');
}
The issue I have is I really don’t want to use the eval() function, is there any better way of doing this?
I apologise for the noobish question, my javascript is a little on the poor side.
Thanks!
You can use square bracket notation to access properties of an object.
example:
x["someProperty"]is identical tox.someProperty.You can use it like this.