This repository was archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path1-variables.js
More file actions
67 lines (62 loc) · 1.79 KB
/
1-variables.js
File metadata and controls
67 lines (62 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
@description
Variables are dynamic representations of a property or given.
In javascript we have three types of declaration for various variables:
@argument var
@description
represents a global or function scope variable, depending on where it is declared.
@argument let
@description
represents a range-only variable from where it is declared.
@argument const
@description
represents a constant variable that does not change after being defined, a constant has to be defined.
@description
By adding the = sign to the side of the variable,
is assigned in the variable the value that is defined.
@example
var variable = 1;
let escopeVariable = 2;
const constantVariable = 3;
**/
/**
@argument var
variable @var variable declared within an object is visible outside its scope.
@example
**/
var variable;
{
var variable = 1;
}
console.log(variable); // 1
/**
Assign new value in the variable.
**/
variable = 2;
console.log(variable); // 2
/**
@argument let
variable @let escopeVariavel declared within an object is not visible outside its scope
@example
**/
let escopeVariable;
{
let escopeVariable = 1;
}
console.log(escopeVariable); // undefined
/**
Assign new value in the variable.
**/
escopeVariable = 1;
console.log(escopeVariable); // 1
/**
@argument const
Váriavel @const constantVariable once declared, it will not be possible to change its value.
@example
**/
const constantVariable = 1;
console.log(constantVariable); // 1
/**
When you assign a new value to the constant, an error will appear.
constantVariable = 2; // error: Assignment to constant variable.
**/