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?
答案 0 :(得分: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.