The toUpperCase() method returns a new string with letters converted to uppercase while leaving the original string unchanged.
const text = "Welcome to Plus2net";
const upper = text.toUpperCase();
console.log(upper); // WELCOME TO PLUS2NET
string.toUpperCase()No argument is required.
const original = "JavaScript";
const changed = original.toUpperCase();
console.log(original); // JavaScript
console.log(changed); // JAVASCRIPT
Result:
input.addEventListener('input', () => {
result.textContent = input.value.toUpperCase();
});See the related keyboard event tutorial.
const role = "ADMIN";
if (role.toUpperCase() === "ADMIN") {
console.log("Matched");
}
const word = "istanbul";
console.log(word.toLocaleUpperCase("tr"));Use toLocaleUpperCase() when language-specific casing matters.
Remember that this method returns a new string. It is a display/data-normalization tool, not a complete solution for locale-aware searching or authentication checks.
Previous / String Reference Next related topic
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| Prakash | 11-03-2010 |
| Well Useful | |