Lets say I've got a JavaScript array like this:

```
var arr=['first','second','third'];

```

And a value like this:

```
var val='bacon';

```

How can I make it so the array and value get translated into an object like this:

```
var obj[first][second][third]='bacon';

```

**Two Important Catches:**

1) The number of elements in the array is always different. So it could just be ['first','second'] or ['first','second','third','fourth'] etc...

2) obj will already exist and needs to not be overwritten with the new value. For example `obj[first][somethingelse]='eggs'` may already exist, and still needs to exist after `obj[first][second][third]='bacon'` is added.

I've tried to come up with various loops and recursive functions to do this. But the variable number of elements in the array keeps tripping me up.