-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatatypes.js
More file actions
46 lines (36 loc) · 771 Bytes
/
datatypes.js
File metadata and controls
46 lines (36 loc) · 771 Bytes
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
// dynamically typed
let a = 1; // number
let b = 4.5;
let c = a + b;
console.log(c);
console.log(typeof c);
/*
assignment =
arithmetic (mathematical) + - * /
*/
// word and number
console.log("hello" + 5);
// **** Some other things to know beforehand ****
// Block scope - undeclared variable
{
x = 5; /* undeclared variable
advised to declare a variable before use
*/
}
console.log(x);
// Block scope with - var
{
var bv = 1;
}
console.log(bv); // var always have global scope
// Block scope with - let
{
let bl = 1;
}
// console.log(bl); // cannot access outside block scope
// variables - var, let, const
let y = 10;
// let y = 20 // cannot re-declare let
var z = 10;
var z = "hello";
console.log(z); // can be re-declared