Search code examples
javascriptv8

How do I know which features are in V8?


I'm a web developer, so my first port of call for any Javascript documentation is usually MDN. For instance, right now I'd like to use the DOMParser, which does have support in Chrome.

However, when I'm running JavaScript through V8 (either Node or rubyracer), DOMParser isn't found.

~/$ node
Welcome to Node.js v12.4.0.
Type ".help" for more information.
> DOMParser;
Thrown:
ReferenceError: DOMParser is not defined
>

Is there a subset of JavaScript which only works in browsers? How do I find out which features V8 supports?


Solution

  • The official, definitive answer is: when it's part of the ECMAScript specification, then it's implemented/supported by ECMAScript engines (V8, SpiderMonkey, JSC). Everything else you find in MDN (for example, anything DOM and network related) is specific to the browser environment, and implemented by the respective browser.

    For an easier reading, MDN's JavaScript reference also seems to maintain that separation.