/html-dom /Basic
GitHub 5008★

Check if the code is running in the browser

We can detect if the current code is running in the browser by checking the existence of window and document objects:

const isBrowser = typeof window === 'object' && typeof document === 'object';

See also

Follow me on and to get more useful contents.