Sunday, 8 September 2013

Set variable for a JS function

Set variable for a JS function

So basically I have a JS function which looks like:
var myFunc = function () {
var settings = {/*my default settings */};
//do something
return {settings:settings};
}()
Now, using the console I can call myFunc.settings and it will perfectly
output these, however I want to user to overwrite the default settings
such as:
<script src="myfunc.js"></script>
<script>myFunc.settings = {/*overwrite some settings*/};</script>
Now myFunc.settings are the new settings, yet the function still uses the
'old' settings. Any clue how I would go about this?
Thanks!

No comments:

Post a Comment