1

Is there any way to assign a variable through a function?

Here's an example:

var test = "foo"

assign(test, "bar")

console.log(test) // "bar"

Of course I know you could do something like this:

var test = "foo"

test = assign(test, "bar")

console.log(test) // "bar"

But I'm curious if it's possible to do this without the direct = assignment.

ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
  • Inside of `assign` there will be local copy of the passed value. So no, you can't make assignment from the function. objects are passed by reference, so you could modify its property then, but complete reassignment would not work anyway. – dfsq Jul 17 '15 at 06:09
  • http://stackoverflow.com/questions/1686990/javascript-variable-reference-alias – Marty Jul 17 '15 at 06:09

0 Answers0