• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

how do I specify I am using ES6 javascript ?

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In html, I just have <script src="my.js"></script>, but how do I specify that this is a ES6 or any other version Javascript ?
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don’t. Why do you feel you need to?
 
Bartender
Posts: 669
15
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The browser will use whatever js it has. You aren't going to run any ES6 on internet explorer no matter what you put in the tag
 
David Mutansan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Al Hobbs wrote:The browser will use whatever js it has. You aren't going to run any ES6 on internet explorer no matter what you put in the tag



Do you mean the browser will auto use the latest javascript version when it interpret a javascript file ? so if the current latest version is ES10,  even it is a dummy alert("hello") browser still uses ES10 to interpret this simple statement ?
 
Al Hobbs
Bartender
Posts: 669
15
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, uses whatever it has to interpret the JS file. Some browsers might not even implement certain parts of the standard. That's why the mozilla docs show what browsers support that particular aspect of the language being documented.

Like if you write a python3 script but your computer has python2 it's not going to work. Whatever the browser has is what is used.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct, the browser applies whatever JS support it has equally to all script. It doesn't evaluate a script for how simple it is and use different versions based upon that.

Most modern browsers will support ES6 syntax pretty much completely. Be aware that browsers take some time to catch up to latest specs.

The "Can I use" site is useful for figuring out what supports what.
 
David Mutansan
Ranch Hand
Posts: 69
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all.
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic