Description

JavaScript Identifiers are used to name keywords, variables, or functions, following the below rules.

  • JavaScript is Case-sensitive, so the identifiers that vary in the case are considered different.
  • Hyphen is reserved for mathematical subtractions, so it cannot be used for other purposes, like naming identifiers.
  • Javascript identifiers must follow the below rules.
    • Must either begin with a letter (A-Z or a-z), a dollar sign ($), or an underscore sign (_).
    • Then subsequent characters may be letters, digits, dollar signs, or underscores.

Most programming languages have the same rules to define identifier names, like JavaScript, Java, PHP, etc.,

var name = "Jack Sparrow";    //Here, the keyword name "var" and variable name "name" are JavaScript identifiers.
console.log(name);    //Logs "Jack Sparrow" to browser console.

name = getName();
console.log(name);    //Logs "John Cena" to browser console.

fun getName(){    //Here, the function name "getName" is a JavaScript identifier.
    return "John Cena";
}

Overall

JavaScript identifiers are used to name keywords, variables, and functions.

Related Links