Is Case Sensitivity Important in JavaScript?

Does JavaScript case sensitivity matter? case sensitivity is a term used to describe the ability of a programming language to distinguish between uppercase and lowercase versions of a language’s character set.

JavaScript is a dynamic language for web scripting. It is most commonly used as a web content language, the implementation of which allows client-side scripts to interact with users and create dynamic pages. It is an interpreted artificial language with object-oriented capabilities.

JavaScript is a case-sensitive language meaning that language keywords, variables, function names, and other identifiers must always be entered in consecutive capital letters.

The ‘hello’ keyword, for instance, should always be typed as “hello”, and not “Hello” or “HELLO”. In like manner, offline, Offline, OffLine and OFFLINE are four different variable names.

However, note that HTML is not case sensitive and due to the close relationship with JavaScript on the client side, this distinction can be confusing. Many JavaScript objects and properties have the same name as the HTML tags and attributes that represent them. While these tags and attribute names can certainly be typed in HTML, they usually have to be written in lower case in JavaScript

For example, the HTML onboard handler attribute is commonly specified as onBoard in HTML but the same must always be referred to as onboard in JavaScript code.

While basic JavaScript is completely and highly case sensitive, exceptions to this rule are allowed in JavaScript by the client. For example, in Internet Explorer 3, all client objects and properties are not case sensitive.

However, this has created incompatibility issues with Netscape, making Internet Explorer 4 and later client objects and properties case sensitive.

<!DOCTYPE html>  

<html>  

<body>  

<h3>JavaScript is case Sensitive language</h3>  

<pidpid=”demo”></p>  

<script>  

var marks, Marks;   

marks=0; //variable 1  

Marks=100; // variable 2  

document.write(Marks);  

 </script>  

 </body>  

</html>  

In the program above, two variables were created, and these are; ‘Marks’ and ‘marks’ and were and assigned them a value of 0.100. In printing the value of the “marks” variable, it prints 100 instead of 0 because in JavaScript, markup and markup are not the same even though both variables are spelt the same.

Importance of case sensitivity

In JavaScript, case sensitivity to is unequivocally important because it affects how language interprets the symbols used. The uniqueness of ‘c’ versus ‘C’ is preserved by language. In other words, it coincides with the inner presentation.

HOW DO I FIND MY NEXT READ?

Similar Articles

Comments

Ads

Most Popular