DEV Community

Discussion on: web-extension - cross-browser compatibility - Firefox, Chrome, Opera in one line

Collapse
 
fjones profile image
FJones • Edited

Even shorter, thanks to short-circuiting, is const nav = chrome || browser; which also allows for more legible chaining past two items - such as falling back to a polyfill or nullobject.

Particularly useful if certain functions may require optional permissions.