I am building JavaScript application and decided to use const
instead of var
in my constant definitions something like this:
const MAX_FILE_SIZE = 50;
const MIN_FILE_SIZE = 5;
const MAX_FILE_COUNT = 10;
...
That makes code more readable to me and I like this, but for some reason, my application failed to work on safari.
What browsers support the const
?
I am building JavaScript application and decided to use const
instead of var
in my constant definitions something like this:
const MAX_FILE_SIZE = 50;
const MIN_FILE_SIZE = 5;
const MAX_FILE_COUNT = 10;
...
That makes code more readable to me and I like this, but for some reason, my application failed to work on safari.
What browsers support the const
?
- 5 caniuse./#feat=const – Quentin Commented May 5, 2016 at 20:15
- developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – Nayuki Commented May 5, 2016 at 20:16
- Seems data from these two sources is not matching for Android or did I get something wrong? One source says "No support" and the other says "Mosty supported" – gevorg Commented May 5, 2016 at 20:18
- I think the info at "Can I use" is slightly more accurate than MDN – Nayuki Commented May 5, 2016 at 20:24
- I happened upon this question and answer and they were useful. I've edited out the only part I can see as "opinion based" - the original question asked about "modern" browsers - and voted to reopen so the useful answer can be viewed by more people. – Warren Dew Commented May 8, 2020 at 16:04
1 Answer
Reset to default 8According to the information pages at Can I use and Mozilla Developer Network, the JavaScript const
feature is supported in:
- Google Chrome 20+ (Jun 2012)
- Mozilla Firefox 13+ (Jun 2012)
- Microsoft Internet Explorer 11+ (Oct 2013)
- Opera 12+ (Jun 2012)
- Safari 5.1+ (Jul 2011)