I'm new to JavaScript so this is possibly a trivial question:

I'm trying to construct an object that stores a mapping from a set of integers to some of its methods, i.e. something like this:

```
'use strict';

function Foo() {
    this.funcs = {
        1: this.func1,
        2: this.func2,
    }
}

Foo.prototype.func1 = function() {
    this.prop = 1;
}

Foo.prototype.func2 = function() {
    this.prop = 2;
}

```

I'd then like to be able to call methods of `Foo` like this:

```
foo = new Foo();
var func = foo.funcs[1];
func();

```

But this results in: `Cannot set property 'prop' of undefined`, i.e. `this` does not refer to `foo`.

What's the problem here and is there a better way to implement this?