Skip to content Skip to sidebar Skip to footer

How To Create Methods With A Loop In Jquery/javascript

I'm having problems trying to register some methods I've created in a loop inside an object. what I'm having is this: var scriptList = { components : [ 'all' ],

Solution 1:

scope.name refers the the name property on scope. If you want to access a property based on a string value, you need to use square bracket notation:

scope[name] = function(){
    window[hookValue] = jQuery('.js-'+name);
    loadAndUse(window[hookValue],key+'/'+name);
}

Post a Comment for "How To Create Methods With A Loop In Jquery/javascript"