Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Identifiers in JavaScript | JavaScript syntax
Introduction to JavaScript (staging)
course content

Course Content

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

Identifiers in JavaScript

What are JavaScript Identifiers

An identifier is simply a name. Identifiers are names given to entities like variables, arrays, functions, classes, etc. In programming, we often store some values in some variables for later use, and for this, we give some names to variables.

Rules for naming Identifier

  • Identifier names must start with a letter, an underscore _, or with a dollar sign $.
1234567891011
//valid identifier name let greeting="hello world"; console.log(greeting); //valid identifier name let _greeting="Good night"; console.log(_greeting); //valid identifier name let $greeting="Good morning"; console.log($greeting);
copy

We got the output without any error which means that all our identifiers are according to JavaScript naming rules.

  • Identifier names cannot start with a number.
1
let 1number=10;
copy

If you run the code you can see the output says SyntaxError: Invalid or unexpected token which means that the token or the identifier we have used is invalid.

  • JavaScript is case-sensitive i.e. greeting is different from Greeting.
1234567
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
copy

Note: JavaScript reserves certain identifiers for use by the language itself. These reserved words cannot be used as regular identifiers. We'll consider it later.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 4
toggle bottom row

Identifiers in JavaScript

What are JavaScript Identifiers

An identifier is simply a name. Identifiers are names given to entities like variables, arrays, functions, classes, etc. In programming, we often store some values in some variables for later use, and for this, we give some names to variables.

Rules for naming Identifier

  • Identifier names must start with a letter, an underscore _, or with a dollar sign $.
1234567891011
//valid identifier name let greeting="hello world"; console.log(greeting); //valid identifier name let _greeting="Good night"; console.log(_greeting); //valid identifier name let $greeting="Good morning"; console.log($greeting);
copy

We got the output without any error which means that all our identifiers are according to JavaScript naming rules.

  • Identifier names cannot start with a number.
1
let 1number=10;
copy

If you run the code you can see the output says SyntaxError: Invalid or unexpected token which means that the token or the identifier we have used is invalid.

  • JavaScript is case-sensitive i.e. greeting is different from Greeting.
1234567
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
copy

Note: JavaScript reserves certain identifiers for use by the language itself. These reserved words cannot be used as regular identifiers. We'll consider it later.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 4
toggle bottom row

Identifiers in JavaScript

What are JavaScript Identifiers

An identifier is simply a name. Identifiers are names given to entities like variables, arrays, functions, classes, etc. In programming, we often store some values in some variables for later use, and for this, we give some names to variables.

Rules for naming Identifier

  • Identifier names must start with a letter, an underscore _, or with a dollar sign $.
1234567891011
//valid identifier name let greeting="hello world"; console.log(greeting); //valid identifier name let _greeting="Good night"; console.log(_greeting); //valid identifier name let $greeting="Good morning"; console.log($greeting);
copy

We got the output without any error which means that all our identifiers are according to JavaScript naming rules.

  • Identifier names cannot start with a number.
1
let 1number=10;
copy

If you run the code you can see the output says SyntaxError: Invalid or unexpected token which means that the token or the identifier we have used is invalid.

  • JavaScript is case-sensitive i.e. greeting is different from Greeting.
1234567
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
copy

Note: JavaScript reserves certain identifiers for use by the language itself. These reserved words cannot be used as regular identifiers. We'll consider it later.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

What are JavaScript Identifiers

An identifier is simply a name. Identifiers are names given to entities like variables, arrays, functions, classes, etc. In programming, we often store some values in some variables for later use, and for this, we give some names to variables.

Rules for naming Identifier

  • Identifier names must start with a letter, an underscore _, or with a dollar sign $.
1234567891011
//valid identifier name let greeting="hello world"; console.log(greeting); //valid identifier name let _greeting="Good night"; console.log(_greeting); //valid identifier name let $greeting="Good morning"; console.log($greeting);
copy

We got the output without any error which means that all our identifiers are according to JavaScript naming rules.

  • Identifier names cannot start with a number.
1
let 1number=10;
copy

If you run the code you can see the output says SyntaxError: Invalid or unexpected token which means that the token or the identifier we have used is invalid.

  • JavaScript is case-sensitive i.e. greeting is different from Greeting.
1234567
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
copy

Note: JavaScript reserves certain identifiers for use by the language itself. These reserved words cannot be used as regular identifiers. We'll consider it later.

Task

In the given javascript code rules for naming, identifiers are violated. Change the following names to make them correct. Then show the values on the console.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 4
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt