From 516d3a958bd60d5fa65a18f7548ec8233314841a Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Mon, 19 Mar 2018 19:28:07 +0200 Subject: [PATCH] Update isBrowser.md --- snippets/isBrowser.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/snippets/isBrowser.md b/snippets/isBrowser.md index 4227234d7..9b50865db 100644 --- a/snippets/isBrowser.md +++ b/snippets/isBrowser.md @@ -1,11 +1,10 @@ ### 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');