Is JavaScript case sensitive language?

Forums JavaScriptIs JavaScript case sensitive language?
Staff asked 2 years ago

Answers (1)

Add Answer
Staff answered 1 year ago

A case-sensitive language is JavaScript. This requires that all terms used as identifiers in a language, including keywords, variables, function names, and others, always have consistent capitalization. For instance, when typing the while keyword, you must use “while”, not “While” or “WHILE”. Similar to how there are four different variable names for online, Online, OnLine, and ONLINE.

But keep in mind that HTML does not care about case. This distinction could be unclear due to its near resemblance to client-side JavaScript. A large number of JavaScript objects and properties share names with the HTML elements and attributes they stand in for. In contrast to HTML, where these tag and attribute names can be entered in any case, JavaScript usually requires that they all be written in lowercase. For instance, the JavaScript code for the HTML onclick event handler property must use the term onclick instead of the more typical onClick.

While client-side JavaScript is permitted to make exceptions from the core JavaScript’s strict case-sensitivity requirement. For instance, all client-side objects and attributes in Internet Explorer 3 were case-insensitive. Client-side objects and attributes are case-sensitive in Internet Explorer 4 and later due to the serious conflicts this caused with Netscape.

Subscribe

Select Categories