How do I create a new object in javascript based on a variable type-string (containing the name of the object)?
Now I have: (with more tools coming the list will get lon
function getTool(name){ return ( typeof window[name] === 'function' ) ? new window[name]() : {/*some default*/}; }
Assumes PointerTool constructor is defined in the global window namespace. Replace that with whatever namespace you're using.
PointerTool
window