
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Why is JavaScript case sensitive but HTML isn't?
A script is in plain text and not just markup like HTML, which is case insensitive. In JavaScript, the while keyword should be "while", not "While" or "WHILE". Case sensitivity is important since it is closely related to HTML, but some methods and events are mentioned differently. JavaScrip has a strict syntax to process the client-side-scripts written in JavaScript.
Some tags and attributes in HTML have the same name as JavaScript objects and properties. In HTML, the attribute and tag names are case-insensitive. The close association of HTML and JavaScript can lead to confusion, so case sensitivity is more important in JavaScript. For example, HTML onclick event attribute is mentioned as onClick in HTML but should be onclick in JavaScript.
The following two words in JavaScript are completely different:
var demo; var DEMO;
The following are different object due to the case-sensitive features of JavaScript:
function Employee(id, name, subject){ this.id = id; this.name = name; } var employee = new Employee("ee1", “John”,”30”);
While working with JavaScript, do check for capitalization of variable, function and object name. This will prevent syntax and other errors.
- Related Articles
- Is JavaScript a case sensitive language?
- Case-sensitive sort in JavaScript
- What's a food that people think is healthy but really isn't?
- Is Python case-sensitive or case-insensitive?
- How to do case-sensitive string comparison in JavaScript?
- 12 Signs Your Antidepressant Isn't Working
- Are Gmail Addresses Case Sensitive
- How to create a variable that can be set only once but isn't final in Java?
- Case sensitive string comparison in Java.
- How MySQL can perform case-sensitive string comparison?
- Are MySQL database and table names case-sensitive?
- How to achieve case sensitive uniqueness and case insensitive search in MySQL?
- Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
- Why isn't sizeof for a struct equal to the sum of sizeof of each member in C/C++?
- Why is case sensitivity so much more important in JavaScript?
