I have below code. This is a kind of Function store that assigns each function an id and then store in the cache:
I thought add method should be able to access properties like nextId and cache which are member of same object. But I have to access it using object reference. Am I doing something wrong here or Is this the way it works?
The function context (what this "points" to), is completely dependent on how you call the function; not how you define the function.
So without seeing how you are calling the functions, we cannot comment on why this is not what you would expect.