Travis build: 1833

This commit is contained in:
30secondsofcode
2018-03-19 17:29:22 +00:00
parent 516d3a958b
commit 29949abafb
2 changed files with 5 additions and 6 deletions

View File

@ -8260,12 +8260,11 @@ Logs: {
### isBrowser
Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node)
without throwing errors.
Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node) without throwing errors.
Use `Array.includes()` on the `typeof` values of both `window` and `document` (globals usually only available in a
browser environment unless they were explicitly defined), which will return `true` if one of them is `undefined`.
`typeof` allows globals to be checked for existence without throwing a ReferenceError. If both of them are not `undefined`, then the current environment is assumed to be a browser.
Use `Array.includes()` on the `typeof` values of both `window` and `document` (globals usually only available in a browser environment unless they were explicitly defined), which will return `true` if one of them is `undefined`.
`typeof` allows globals to be checked for existence without throwing a `ReferenceError`.
If both of them are not `undefined`, then the current environment is assumed to be a browser.
```js
const isBrowser = () => ![typeof window, typeof document].includes('undefined');