Merge pull request #2 from atimidguy/atimidguy-patch-2

Atimidguy patch 2
This commit is contained in:
atimidguy 2019-08-28 20:09:53 +08:00 committed by GitHub
commit c598888dce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -124,7 +124,7 @@ arr.slice(start, end)
It returns a new array copying to it all items from index `start` to `end` (not including `end`). Both `start` and `end` can be negative, in that case position from array end is assumed.
It's similar to a string method `str.slice`, but instead of substringss it makes subarrays.
It's similar to a string method `str.slice`, but instead of substrings it makes subarrays.
For instance:

View file

@ -347,6 +347,8 @@ If the function is declared as a Function Expression (not in the main code flow)
Also, functions may carry additional properties. Many well-known JavaScript libraries make great use of this feature.
They create a "main" function and attach many other "helper" functions to it. For instance, the [jQuery](https://jquery.com) library creates a function named `$`. The [lodash](https://lodash.com) library creates a function `_`. And then adds `_.clone`, `_.keyBy` and other properties to it (see the [docs](https://lodash.com/docs) when you want learn more about them). Actually, they do it to lessen their pollution of the global space, so that a single library gives only one global variable. That reduces the possibility of naming conflicts.
They create a "main" function and attach many other "helper" functions to it. For instance, the [jQuery](https://jquery.com) library creates a function named `$`. The [lodash](https://lodash.com) library creates a function `_`, and then adds `_.clone`, `_.keyBy` and other properties to it (see the [docs](https://lodash.com/docs) when you want learn more about them). Actually, they do it to lessen their pollution of the global space, so that a single library gives only one global variable. That reduces the possibility of naming conflicts.
So, a function can do a useful job by itself and also carry a bunch of other functionality in properties.