can-symbol
Version:
Well known symbols used to detail how to operate on different objects
24 lines (16 loc) • 876 B
Markdown
String)} can-symbol/symbols/hasKey can.hasKey
can-symbol/symbols/shape
Define a function to determine key membership of an object or an object on its prototype chain
`@ .hasKey(key)`
The `@@@ .hasKey` symbol points to a function on an object that, given a String key, determines whether the key is a member of the object's key set or the key set of an object on its prototype chain.
```
var obj = {
secrets: [ "garden", "santa", "service" ]
};
obj[canSymbol('can.hasKey')] = function(key) {
return key in this || key in this.secrets;
};
```
{Object} any object with key properties
{String} key the string key for which to test membership in the object
{Boolean} true if there is a property on the object or on an object in the objects prototype chain with a matching key, false otherwise.
{function(