I have a function which you can pass an object to. I then need all the vars within this object to become local variables. For instance
function ping(){
alert(riff); //'raff'
}
ping({
riff: 'raff'
});
The only way I can think to do it is looping the object and setting them one by one but that seems clunky. Any alternatives?
Edit: the return was to show what that variable would be like. The main thing I don’t want is to have to go through another object to get to the data. I want the structure to be
function.riff = 'raff'
rather than
function.settings.riff = 'raff'
This currently the best answer I can come up with… any advances on this?
Note how the vars are added directly into the function rather than through an object in the function.
This is because I want to be able to overwrite private function vars with this object before they are used.