-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables_types.js
47 lines (35 loc) · 1.12 KB
/
variables_types.js
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
/* 5 Primitive Types:
1. Number
2. String
3. Boolean
4. Undefined
5. Null
*/
// Undefined type:
var c;
document.write(" c = " + c); // O/P: c = undefined
// Number type:
var n = 75;
document.write("<br/> n = " + n); // O/P: n = 75
var f = 75.2;
document.write("<br/> f = " + f); // O/P: f = 75.2
// We can even use Scientific Notation for Floating Point Numbers
// for example, 7.2e2 or 7.2E2 means 720.0
var e = 7.2e2;
document.write("<br/> e = " + e); // O/P: e = 720
e = 7.2E-2;
document.write("<br/> e = " + e); // O/P: e = 0.072
// String Type:
// Enclosed in either '' or "". Some String Literals like
// ", ', \, etc are Escaped by Backslash (\)
var s = "You\'re the most \"insane\"\\\"crazy\" person I\'ve seen till now!"
document.write("<br/> s = " + s)
// O/P: s = You're the most "insane"\"crazy" person I've seen till now!
// Boolean Type:
var mayday = false;
var birthday = true;
document.write("<br/> mayday = " + mayday); // O/P: mayday = false;
document.write("<br/> birthday = " + birthday); // O/P: birthday = true;
// Null Type:
var x = null;
document.write("<br/> x = " + x); // O/P: x = null