Skip to content

Commit f6df0fc

Browse files
authored
Change var to const (ronreiter#700)
1 parent b532fa3 commit f6df0fc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tutorials/learn-js.org/en/Variables and Types.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Like almost every dynamic language, JavaScript is a "duck-typed" language, and t
55

66
We can define several types of variables to use in our code:
77

8-
var myNumber = 3; // a number
9-
var myString = "Hello, World!" // a string
10-
var myBoolean = true; // a boolean
8+
const myNumber = 3; // a number
9+
const myString = "Hello, World!" // a string
10+
const myBoolean = true; // a boolean
1111

1212
A few notes about variable types in JavaScript:
1313

@@ -16,19 +16,19 @@ A few notes about variable types in JavaScript:
1616

1717
There are two more advanced types in JavaScript. An array, and an object. We will get to them in more advanced tutorials.
1818

19-
var myArray = []; // an array
20-
var myObject = {}; // an object
19+
const myArray = []; // an array
20+
const myObject = {}; // an object
2121

2222
On top of that, there are two special types called `undefined` and `null`.
2323

2424
When a variable is used without first defining a value for it, it is equal to undefined. For example:
2525

26-
var newVariable;
26+
const newVariable;
2727
console.log(newVariable); //prints undefined
2828

2929
However, the `null` value is a different type of value, and is used when a variable should be marked as empty. `undefined` can be used for this purpose, but it should not be used.
3030

31-
var emptyVariable = null;
31+
const emptyVariable = null;
3232
console.log(emptyVariable);
3333

3434

@@ -59,9 +59,9 @@ myBoolean is equal to false
5959

6060
Solution
6161
--------
62-
var myNumber=4;
63-
var myString="Variables are great.";
64-
var myBoolean=false;
62+
const myNumber=4;
63+
const myString="Variables are great.";
64+
const myBoolean=false;
6565
console.log("myNumber is equal to " + myNumber);
6666
console.log("myString is equal to " + myString);
6767
console.log("myBoolean is equal to " + myBoolean);

0 commit comments

Comments
 (0)