MrBrody
MrBrody

Reputation: 301

What is the 'char' keyword used for?

What is the char reserved keyword used for in JavaScript (as type declaration is not necessary), and especially, what is the correct syntax to use it (could someone give me a proper full example)?

Because writing char c; throws an interpretation error saying missing ; before statement, just before the c?

Upvotes: 11

Views: 8234

Answers (3)

Sarfraz
Sarfraz

Reputation: 382726

Update:

Also as @HoLyVieR pointed out and shown in comments below, char keyword is reserved for future use. See this link for more information (Thanks to @djmadscribbler) .


There is no reserved keyword char in JavaScript, you must be confusing it with reserved keyword char of Java instead.

Upvotes: 3

HoLyVieR
HoLyVieR

Reputation: 11134

There are a lot of reserved keyword in JavaScript that are reserved for "future" use. They don't necessarily have a current use and a description.

MDN does list some of them that have this special "future use" status here : https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words (thanks to DCoder) and you can also read from that article :

The following are reserved as future keywords by the ECMAScript specification. They have no special functionality at present, but they might at some future time, so they cannot be used as identifiers. These keywords may not be used in either strict or non-strict mode.

To expand a little further as to why it's consider a reserved keyword in some places and in some places it's not. The ECMAScript v3 specification did include char as a reserved keyword, but the ECMAScript v5 specification (which is starting to be the most common one) does not include it.

Upvotes: 19

Rick
Rick

Reputation: 1573

According to the ECMAscript documentation ( http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf section 7.6.1 ) char isn't a reserved word at all.

I'm guessing if you're seeing that as a reserved word somewhere then it's a specific implementation.

http://jsfiddle.net/BCruP/

Edit: Above reference was EMCAscript 5.

EMCAScript 3 ( http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf ) documentation lists char as a future reserved word, however, EMCAScript 5 seems to have dropped that off the list.

Upvotes: 2

Related Questions