0

I would like to pass function parameters as parts of my function code.

function update(value, key) {
    $localStorage.key = value;
}

If I call my function with, lets say :

update(20, age);

The value (20) will be correctly used, but the key will be treated as 'key' not as 'age', thus saving content in a wrong object reference.

Any idea for a quick fix ?

georg
  • 211,518
  • 52
  • 313
  • 390
yts
  • 39
  • 1
  • 4

0 Answers0