Contenido del Curso
Introduction to JavaScript (staging)
Introduction to JavaScript (staging)
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$
.
//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);
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.
let 1number=10;
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.
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
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.
Tarea
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.
¡Gracias por tus comentarios!
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$
.
//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);
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.
let 1number=10;
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.
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
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.
Tarea
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.
¡Gracias por tus comentarios!
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$
.
//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);
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.
let 1number=10;
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.
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
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.
Tarea
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.
¡Gracias por tus comentarios!
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$
.
//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);
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.
let 1number=10;
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.
//different identifier name from below let Greeting ="hello world"; console.log(Greeting); //valid identifier name from above let greeting="good morning"; console.log(greeting);
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.
Tarea
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.