最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What browsers support javascript constants? - Stack Overflow

programmeradmin5浏览0评论

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?

Share Improve this question edited May 9, 2020 at 0:48 AmerllicA 32.7k17 gold badges144 silver badges167 bronze badges asked May 5, 2016 at 20:14 gevorggevorg 5,0655 gold badges38 silver badges54 bronze badges 6
  • 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
 |  Show 1 more ment

1 Answer 1

Reset to default 8

According 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)
发布评论

评论列表(0)

  1. 暂无评论