Gravatar for

Question by iker_netcentric, Mar 16, 2016 4:15 AM

Why are you using reserved words like 'char' and 'float' as variable names?

I'm working with the CoveoJsSearch framework and although you have the minified version of it I work with AEM which does its own minification process so I choose to use the non-minified version, when AEM starts the minification process it first lints the file and found variables names like 'char' or 'float' which it takes as reserved words and throws an error.

It is really bad practice to use reserved words such as 'char' and 'float' as variable names. More than a question this is more of a feedback so you can improve your code.

Although Javascript and almost all browser don't care about these specific reserved words, they are native types of any other programming language. Hope you can see my point.

1 Reply
Gravatar for

Answer by Martin Laporte, Mar 16, 2016 9:42 AM

Yes we absolutely see your point. I discussed that with a few folks this morning, and it was pointed out that those keywords are only reserved in older versions of the ECMAScript standard --- on newer versions (ES3+) they no longer are. Some more info here:

All of our JS UI code is in fact compiled through TypeScript (targeting ES5), and any usage of a "current" reserved word results in a compilation error, but those that are no longer reserved now don't trigger this.

So we're still debating whether we should change this or not, but thanks a lot for the heads up :)

Ask a question