JavaScript Case Sensitivity
JavaScript Case Sensitivity
JavaScript is a case-sensitive language. This means that the JavaScript engine treats every uppercase and lowercase letter as a distinct character. name, Name, and NAME are three completely separate identifiers — they have nothing to do with each other.
This applies everywhere: variable names, function names, object properties, class names, keywords, and all built-in browser APIs.
One of the most common beginner mistakes
Typing Console.log() instead of console.log() or document.GetElementById() instead of document.getElementById() causes a ReferenceError or TypeError. The engine sees these as completely different names.
Identifiers
Variable, function, and class names are all case-sensitive. user, User, and USER are different.
Keywords
JavaScript keywords are all lowercase: let, const, if, return. Writing Let or RETURN is a SyntaxError.
Built-ins & APIs
console.log, document.getElementById, Math.random — every character's case is fixed.
Conventions
camelCase for variables/functions, PascalCase for classes, UPPER_SNAKE for constants.
Case Sensitivity in Identifiers
Case Sensitivity in Identifiers
An identifier is any name you create — for a variable, function, parameter, class, or object property. Every identifier is case-sensitive. The engine compares character by character, and a single different case means a completely different identifier.
1// These are THREE different variables2let score = 100;3let Score = 200;4let SCORE = 300;56console.log(score); // 1007console.log(Score); // 2008console.log(SCORE); // 300910// Same applies to functions11function greet() { return 'hello'; }12function Greet() { return 'HELLO'; }1314console.log(greet()); // 'hello'15console.log(Greet()); // 'HELLO'1617// And object properties18const user = {19 name: 'Alice',20 Name: 'Bob', // different property!21 NAME: 'Carol' // yet another!22};2324console.log(user.name); // 'Alice'25console.log(user.Name); // 'Bob'26console.log(user.NAME); // 'Carol'
Never define two identifiers that differ only by case
While JavaScript allows let data and let Data in the same scope, never do this. It causes extreme confusion, makes code unmaintainable, and is virtually impossible to read correctly at a glance. Use meaningful, distinct names instead.
Keywords Are Always Lowercase
Keywords Are Always Lowercase
All JavaScript reserved keywords are lowercase. They are fixed — you cannot change their case. Writing Let, Const, IF, or RETURN causes a SyntaxError because the engine doesn't recognise them as keywords.
1// ✅ Correct — all keywords lowercase2const PI = 3.14159;3let count = 0;45function add(a, b) {6 return a + b;7}89if (count === 0) {10 console.log('Zero');11}1213for (let i = 0; i < 3; i++) {14 console.log(i);15}1617// ❌ These ALL cause SyntaxError:18// Const x = 5;19// Let y = 10;20// IF (true) { }21// RETURN 42;22// Function foo() { }2324console.log(add(2, 3)); // 5
| Correct ✅ | Wrong ❌ | Error Type |
|---|---|---|
| let | Let / LET | SyntaxError |
| const | Const / CONST | SyntaxError |
| var | Var / VAR | SyntaxError |
| if / else | If / IF / Else | SyntaxError |
| for / while | For / While | SyntaxError |
| function | Function / FUNCTION | SyntaxError |
| return | Return / RETURN | SyntaxError |
| class | Class / CLASS | SyntaxError |
| import / export | Import / Export | SyntaxError |
| true / false / null | True / False / Null | SyntaxError |
Built-in APIs and Case
Built-in APIs and Case
All JavaScript built-in objects, methods, and browser APIs have fixed, case-sensitive names. The most common mistakes happen with the global console object and DOM methods.
1// ✅ console — all lowercase2console.log('hello');3console.warn('warning');4console.error('error');5console.table([1, 2, 3]);67// ❌ These FAIL — TypeError: Console is not defined8// Console.log('hello');9// CONSOLE.LOG('hello');1011// ✅ Math object — capital M, lowercase methods12console.log(Math.random()); // 0 to 113console.log(Math.floor(4.9)); // 414console.log(Math.max(1, 5)); // 515console.log(Math.PI); // 3.14159...1617// ❌ Wrong casing for Math18// console.log(math.random()); // ReferenceError19// console.log(Math.Random()); // TypeError2021// ✅ Array methods — all lowercase22const nums = [3, 1, 2];23nums.sort();24console.log(nums); // [1, 2, 3]2526// ❌ Wrong27// nums.Sort(); // TypeError
camelCase vs PascalCase vs UPPER_CASE
Naming Conventions
JavaScript doesn't enforce naming conventions — the engine doesn't care if you use camelCase or snake_case. But the community has settled on consistent conventions that every developer follows. Using the right convention makes your code immediately readable to any JavaScript developer.
| camelCase | PascalCase |
|---|---|
| Used for variables and function names | Used for class names and constructor functions |
| First word lowercase, each subsequent word capitalised | Every word starts with a capital letter |
| Examples: userName, getUserData, isLoggedIn, fetchPageCount | Examples: User, UserProfile, HttpRequest, EventEmitter |
| Most common style in JavaScript — use it for everything that isn't a class or constant | When you see PascalCase, you immediately know it's a class or component (React) |
1// camelCase — variables and functions2let userName = 'Alice';3let isLoggedIn = true;4let totalItemCount = 0;56function getUserProfile(userId) {7 return { id: userId, name: userName };8}910function calculateTotalPrice(items) {11 return items.reduce((sum, item) => sum + item.price, 0);12}1314// PascalCase — classes and constructor functions15class UserAccount {16 constructor(name, email) {17 this.name = name;18 this.email = email;19 }2021 getDisplayName() {22 return this.name;23 }24}2526// UPPER_SNAKE_CASE — constants that never change27const MAX_RETRY_COUNT = 3;28const API_BASE_URL = 'https://api.example.com';29const DEFAULT_TIMEOUT_MS = 5000;3031// Usage32const account = new UserAccount('Bob', 'bob@example.com');33console.log(account.getDisplayName()); // 'Bob'34console.log(getUserProfile(1)); // { id: 1, name: 'Alice' }35console.log(MAX_RETRY_COUNT); // 3
| What | Convention | Example |
|---|---|---|
| Variables | camelCase | firstName, isActive, itemCount |
| Functions | camelCase | getUserData(), handleClick(), formatDate() |
| Classes | PascalCase | User, EventEmitter, HttpClient |
| Constants (fixed values) | UPPER_SNAKE_CASE | MAX_SIZE, API_URL, DEFAULT_LIMIT |
| Private fields (convention) | _camelCase | _userId, _cache, _isReady |
| Boolean variables | camelCase with is/has/can | isLoggedIn, hasError, canEdit |
| Event handlers | camelCase with on/handle | onClick, handleSubmit, onKeyDown |
| React components | PascalCase | NavBar, UserCard, LoginForm |
Common Case Mistakes
Common Case Mistakes to Avoid
1// ❌ MISTAKE 1: Wrong console casing2// Console.log('hello'); // ReferenceError: Console is not defined3// console.Log('hello'); // TypeError: console.Log is not a function4console.log('✅ console.log works'); // correct56// ❌ MISTAKE 2: Wrong Math method casing7// Math.Round(4.5) // TypeError: Math.Round is not a function8console.log(Math.round(4.5)); // ✅ 5910// ❌ MISTAKE 3: Wrong JSON method casing11// JSON.Parse('{"a":1}') // TypeError12// JSON.Stringify({ a: 1 }) // TypeError13console.log(JSON.parse('{"a":1}')); // ✅ { a: 1 }1415// ❌ MISTAKE 4: Wrong array method casing16const arr = [1, 2, 3];17// arr.Map(x => x * 2) // TypeError18// arr.Filter(x => x > 1) // TypeError19console.log(arr.map(x => x * 2)); // ✅ [2, 4, 6]20console.log(arr.filter(x => x > 1)); // ✅ [2, 3]2122// ❌ MISTAKE 5: Typo creates a new variable silently (var era)23// var userName = 'Alice';24// console.log(username); // undefined — not an error with var! Bug.2526// ✅ With let/const this IS an error (helpful)27const firstName = 'Alice';28// console.log(firstname); // ReferenceError — caught immediately!
Use TypeScript or a linter to catch case mistakes
TypeScript will instantly flag Console.log or Math.Round as type errors before you even run your code. ESLint with the no-undef rule also catches references to undefined names. Both tools eliminate the entire class of case-typo bugs.
Test Your Knowledge
Test Your Knowledge
What will happen when you run: Console.log('hello');
Which variable declaration will cause a SyntaxError?
What naming convention should you use for JavaScript class names?
Are count and Count the same variable in JavaScript?
Which of the following is the correct way to call the Math rounding method?
Quick Reference
Case Sensitivity Quick Reference
- 1JavaScript is 100% case-sensitive — every letter in every identifier matters.
- 2All keywords are lowercase:
let,const,if,else,for,while,return,class,import. - 3
consoleis all lowercase.MathandJSONstart with uppercase.NaN,Infinity,undefinedare lowercase. - 4Use camelCase for variables and functions:
getUserData,isLoggedIn,totalCount. - 5Use PascalCase for classes and constructors:
User,EventHandler,HttpClient. - 6Use UPPER_SNAKE_CASE for top-level constants:
MAX_SIZE,API_URL,DEFAULT_TIMEOUT. - 7Use TypeScript or ESLint to catch case typos instantly — before they become runtime bugs.
- 8Never create two identifiers in the same scope that differ only by case — it is a maintenance nightmare.
Statements & Semicolons
How statements work, when semicolons are required, and ASI pitfalls.
Comments
Single-line, multi-line, and JSDoc comments — how and when to use them.
Variables
let, const, var — declarations, scope, hoisting, and when to use each.
Functions
Function declarations, expressions, arrow functions, and scope.
You understand JavaScript case sensitivity!
You now know that JavaScript distinguishes every letter's case in identifiers, keywords, and built-in APIs. You also know the community naming conventions — camelCase, PascalCase, and UPPER_SNAKE_CASE — that make JavaScript code consistent and readable.
Try it in the Javascript Compiler
Run and experiment with Javascript code right in your browser — no setup needed.