javascriptv8spidermonkeyjavascript-enginechakra

How can I determine the JavaScript Engine from .js code?


Is there a way using JavaScript code to know what JavaScript Engine, is the one on which that code is run on?

I don't want to get the browser type just the JavaScript engine.


Solution

  • See How can I detect which javascript engine (v8 or JSC) is used at runtime in Android? for some JavaScript code that uses feature detection to determine the platform.

    Also:

    I think the better question is: Why do you care? You're basically falling into the "browser detection" trap that a lot of people fell into in the late 90's / early 00's. Since then, though, we've learned that it's feature detection that's the more useful approach, not least because the features supported in a given browser were (mostly) a moving target. There's code now, running on IE9 with its dramatically-improved DOM and JavaScript support, that's not using those features because it's doing browser detection and falling back on IE6 techniques.

    from: https://stackoverflow.com/a/6768595/1183010