1

I'm trying to check if the user's from Google Chrome has activate the flag #enable-javascript-harmony.

I have no idea how to do it.

Any help will be appreciate.

Alvaro Silvino
  • 9,441
  • 12
  • 52
  • 80
  • you can test if a es6 feature exists. For example: typeof(Promise) – Gaël Barbin Dec 25 '15 at 06:54
  • It's a good Idea but seams to be a work around.... what you think? is there a better solution? @Gael – Alvaro Silvino Dec 25 '15 at 06:55
  • 1
    it is the method employed by scripts like modernizr to check if a feature is available. And whatever, you should check any browser specific method before using it. For me, it is not just a work-around solution. – Gaël Barbin Dec 25 '15 at 08:03
  • @Gael Thanks, I you are right! – Alvaro Silvino Dec 25 '15 at 14:04
  • 1
    Do note, any feature detection specific to things under the flag are a constant moving target. So, if you really need to know if the flag is on, there is no sure-fire way to know. Site's can't query flag state. – Garbee Dec 25 '15 at 16:01
  • In short, check the features that you want use, regardless of how they are brought on the environment. – Gaël Barbin Dec 25 '15 at 20:06

1 Answers1

3

Chrome flag enable-javascript-harmony turns on the V8 switch --harmony.

You can check if it is enabled by testing some ES Next functions from http://node.green (with a flag in the first column), e.g.:

const regexGreekSymbol = /\p{Script=Greek}/u;
regexGreekSymbol.test('π');

This returns true when ES Harmony is turned on and Uncaught SyntaxError: Invalid regular expression: /\p{Script=Greek}/: Invalid escape otherwise.

niutech
  • 28,923
  • 15
  • 96
  • 106