1

In the docs for angular-cache, the author uses this nomenclature:

Cache#get(key[, options])

Return the item with the given key. options, if provided, must be an object.

If the cache is in passive mode, then options.onExpire can be a function that will be called with the key and value of the requested item if the requested item is expired, with the get call itself returning undefined.

The function is called simply by Cache.get(key). So what does the #, and why is it used?

random_user_name
  • 23,924
  • 7
  • 69
  • 103

1 Answers1

1

Classes can have static methods and prototype methods.

Static methods are available on the class itself, and prototype methods are inherited by the instances of the class.

For example, with arrays,

  • Array.from is a static method. Using it on instances like [].from won't work.
  • Array.prototype.slice is a prototype method. You can use it on instances like [].slice

To avoid writing prototype, some people use the # notation to refer to prototype methods. In the example above, they would say Array#slice. Note this notation is only used when talking about JavaScript, but you can't use it in the code itself.

Oriol
  • 225,583
  • 46
  • 371
  • 457
  • Excellent, thanks! Does this belong over here, also?: http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript – random_user_name Feb 12 '16 at 20:03
  • @cale_b Not sure, because in fact it's not JS syntax. Maybe it could be called meta-syntax – Oriol Feb 12 '16 at 20:05