Checks if the current runtime environment is a browser.
This function helps detect whether code is executing in a web browser by confirming the existence of the global window and document objects.
window
document
true if running in a browser, otherwise false.
true
false
if (isBrowser()) { console.log('Running in a browser environment');} Copy
if (isBrowser()) { console.log('Running in a browser environment');}
Checks if the current runtime environment is a browser.
This function helps detect whether code is executing in a web browser by confirming the existence of the global
window
anddocument
objects.