querySelectorAll. Returns a NodeList → fails until you use [0].
Fake object. Underscore’s duck-type check still returns true.
Caution. Prefer real DOM nodes; Lodash rejects this forge.
Compatibility
Browser & Runtime Support
_.isElement ships with Underscore.js (1.x). It is most useful in browsers with a real DOM. In Node.js it still runs, but you need a DOM shim (e.g. jsdom) for real element values.
✓ Stable · Underscore 1.x
_.isElement()
Available in [email protected] (UMD / ESM). Works in evergreen browsers when Underscore is loaded. Node.js needs a DOM environment for meaningful element checks.
100%With Underscore 1.x + DOM
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.isElementUnderscore 1.x+
Bottom line: Safe for browser production once Underscore is loaded. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.isElement(object) returns true when the value looks like a DOM element node — it is truthy and its nodeType is 1. That matches <div>, <span>, document.body, and SVG tags.
A jQuery object is a collection, not a DOM node. [0] (or .get(0)) unwraps the first raw element. _.isElement(jQuery('body')) is false; _.isElement(jQuery('body')[0]) is true. document.body is the vanilla equivalent.
No. Text nodes have nodeType 3, comments 8, documents 9, and fragments 11. Only element nodes (nodeType 1) pass.
Yes in Underscore. The helper is roughly !!(obj && obj.nodeType === 1). It does not prove the value came from the DOM. Lodash is stricter and rejects plain objects.
Yes. SVG elements are still element nodes with nodeType 1. The helper is not limited to HTML tag names.
No. It is a stable Underscore 1.x helper. Use it in the browser (or with a DOM shim such as jsdom) before treating a value as an element.