Why is "float" a reserved word in JavaScript? - Stack Overflow

I just found myself writting a variable called float and Sublime Text made it blue, like it would with

I just found myself writting a variable called float and Sublime Text made it blue, like it would with "document" or "window". Then I tried to write that in Chrome's console and see what it was... but it seems like, at least, it is not a global variable.

What is float in Javascript and why is it a reserved word? May it be for a possible future use?

EDIT: For those downvoting: I found it actually is a reserved word here: .asp

EDIT2: As ES6 is adding real classes to JS, and it seems JS is looking more and more like Java, could it be possible that in the future you'd have to define a variable as Float my_number = 1.1234; ?

I just found myself writting a variable called float and Sublime Text made it blue, like it would with "document" or "window". Then I tried to write that in Chrome's console and see what it was... but it seems like, at least, it is not a global variable.

What is float in Javascript and why is it a reserved word? May it be for a possible future use?

EDIT: For those downvoting: I found it actually is a reserved word here: http://www.w3schools./js/js_reserved.asp

EDIT2: As ES6 is adding real classes to JS, and it seems JS is looking more and more like Java, could it be possible that in the future you'd have to define a variable as Float my_number = 1.1234; ?

Share Improve this question edited Sep 10, 2015 at 10:43 Vandervals asked Sep 10, 2015 at 10:36 VandervalsVandervals 6,1048 gold badges53 silver badges101 bronze badges 6
  • Why is “float” a reserved word in JavaScript? - it's not. Probably some incorrect highlighting rules in your sublime – Andrey Commented Sep 10, 2015 at 10:38
  • @Andrey developer.mozilla/en-US/docs/Web/JavaScript/Reference/… actually it is.. – Jorge Y. C. Rodriguez Commented Sep 10, 2015 at 10:38
  • 1 Well, OK. It was. Because now ES5 is everywhere and ES2015 is ongoing. – Andrey Commented Sep 10, 2015 at 10:39
  • @jycr753 Future reserved keywords in older standards The following are reserved as future keywords by older ECMAScript specifications (ECMAScript 1 till 3). – Tushar Commented Sep 10, 2015 at 10:39
  • @Andrey well it was. but I guess they still hight light it for the same reason a lot people still uses IE 8 – Jorge Y. C. Rodriguez Commented Sep 10, 2015 at 10:40
 |  Show 1 more ment

1 Answer 1

Reset to default 12

Float is NOT reserved in the current ECMAScript (4-5) or in the uping version (6), but was in previous specificiations.

The official reason:

Future reserved keywords in older standards

The following are reserved as future keywords by older ECMAScript specifications (ECMAScript 1 till 3).

abstract - boolean - byte - char - double - final - float - goto - int - long - native - short - synchronized - transient - volatile

Additionally, the literals null, true, and false are reserved in ECMAScript for their normal uses.

The entire information can be read here

For those who still don't believe me the float in this jsFiddle is a lie

var float = "definitively not a float";

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745105079a4611507.html

相关推荐

  • Why is "float" a reserved word in JavaScript? - Stack Overflow

    I just found myself writting a variable called float and Sublime Text made it blue, like it would with

    16小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信