Constans in Javascript

Forums » Opera for Windows/Mac/Linux » Opera browser

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

16. April 2010, 21:04:30

BS-Harou

Posts: 231

Constans in Javascript

When I run this script in Firefox or Chrome, the result is 5, but in Opera It is 3 .. is it intention, that its possible to change constants in javascript in Opera or is it bug?

{script}
const a = 5;
a = 3;
alert(a);
{/script}

16. April 2010, 22:16:48

xErath

javascript guru

Posts: 6588

There is no such thing as constants in ecmascript. That's a Mozilla specific extension.
For a collection of user scripts visit
http://my.opera.com/xErath/blog/

17. April 2010, 22:40:36

BS-Harou

Posts: 231

I know but opera actually supports "const" keyword. It just works like "var" p

And because both webkit and gecko doesn't allow to change constants I think that Opera should not allow that too. (and mainly because its the reason why constants are used)

Anyway, imo in next version of ecmascript this will be solved =)

Forums » Opera for Windows/Mac/Linux » Opera browser