Travis build: 1441
This commit is contained in:
36
README.md
36
README.md
@ -304,6 +304,7 @@ average(1, 2, 3);
|
||||
<details>
|
||||
<summary>View contents</summary>
|
||||
|
||||
* [`bindAll`](#bindall)
|
||||
* [`deepClone`](#deepclone)
|
||||
* [`defaults`](#defaults)
|
||||
* [`equals`](#equals-)
|
||||
@ -5100,6 +5101,41 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
|
||||
---
|
||||
## 🗃️ Object
|
||||
|
||||
### bindAll
|
||||
|
||||
Explain briefly what the snippet does.
|
||||
|
||||
Use `Array.forEach()` to return a `function` that uses `Function.apply()` to apply the given context (`obj`) to `fn` for each function specified.
|
||||
|
||||
```js
|
||||
const bindAll = (obj, ...fns) =>
|
||||
fns.forEach(
|
||||
fn =>
|
||||
(obj[fn] = function() {
|
||||
return fn.apply(obj);
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
var view = {
|
||||
label: 'docs',
|
||||
click: function() {
|
||||
console.log('clicked ' + this.label);
|
||||
}
|
||||
};
|
||||
bindAll(view, 'click');
|
||||
jQuery(element).on('click', view.click); // Logs 'clicked docs' when clicked.
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### deepClone
|
||||
|
||||
Creates a deep clone of an object.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -16,8 +16,8 @@ const bindAll = (obj, ...fns) =>
|
||||
|
||||
```js
|
||||
var view = {
|
||||
'label': 'docs',
|
||||
'click': function() {
|
||||
label: 'docs',
|
||||
click: function() {
|
||||
console.log('clicked ' + this.label);
|
||||
}
|
||||
};
|
||||
|
||||
@ -215,7 +215,7 @@ sortedLastIndexBy:array,math,function
|
||||
splitLines:string
|
||||
spreadOver:adapter
|
||||
standardDeviation:math,array
|
||||
stripHTMLTags:string,utility,regexp
|
||||
stripHTMLtags:uncategorized
|
||||
sum:math,array
|
||||
sumBy:math,array,function
|
||||
sumPower:math
|
||||
|
||||
Reference in New Issue
Block a user