-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjs_basics_2.html
More file actions
101 lines (63 loc) · 2.42 KB
/
Copy pathjs_basics_2.html
File metadata and controls
101 lines (63 loc) · 2.42 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<script>
/*
alert(asdfgh); //It will throw error as 'asdfgh' is not declared anywhere on this script
alert(myVariable); //this will show 'undefined' but does not throw ERROR. because 'myVariable' is set on line 68
var aVariableWithoutValue;
var aString = 'Hello';//anything enclosed by ''
var anotherString = "Hi";//""
var aNumber = 12;//
var aBoolean = true;//true
var aVariableWithValueNull = null;
var aStringLookLikeNumber = '12';
var aStringLookLikeBoolean = 'true';
var anEmptyString = "";
var aNaN = 12*'abc';
function aFunction(){
};
function anotherFunction(){
return;
};
function anotherFunctionReturningNull(){
return null;
};
try{
var aUndefinedFromFunction = aFunction();
var aUndefinedFromFunction2 = anotherFunction();
var aNullFromFunction = anotherFunctionReturningNull();
var aDiv = document.getElementById('myId');
alert(//aVariableWhichIsnotDefined +"\n"+
typeof aVariableWithoutValue +" with a value :"+ aVariableWithoutValue +"\n" +
typeof aString +" with a value :"+ aString +"\n"+
typeof anotherString +" with a value :"+ anotherString +"\n"+
typeof aNumber +" with a value :"+ aNumber +"\n"+
typeof aBoolean +" with a value :"+ aBoolean +"\n"+
typeof aVariableWithValueNull +" with a value :"+ aVariableWithValueNull +"\n"+
typeof aStringLookLikeNumber +" with a value :"+ aStringLookLikeNumber +"\n"+
typeof aStringLookLikeBoolean +" with a value :"+ aStringLookLikeBoolean +"\n"+
typeof anEmptyString +" with a value :"+ anEmptyString +"\n"+
typeof aNaN +" with a value :"+ aNaN +"\n"+
typeof aUndefinedFromFunction +" with a value :"+ aUndefinedFromFunction +"\n"+
typeof aFunction +" with a value :"+ aFunction +"\n"+
typeof aUndefinedFromFunction2 +" with a value :"+ aUndefinedFromFunction2 +"\n"+
typeof aNullFromFunction +" with a value :"+ aNullFromFunction +"\n"+
typeof aDiv +" with a value :"+ aDiv +"\n"
);
}catch(e){
alert(e.message+"\n"+e.name);
}
var myVariable = 'hi';
alert(myVariable);
*/
//type casting: Converting Data Type
/*
var aString1 = 'abc';
alert(Number(aString1));
var aString2 = '12';
alert(typeof Number(aString2));
var aNumber = 12;
alert(typeof aNumber.toString());
alert(Number('12abc')+"\n"+Number('abc12'));
alert(parseInt('12abc')+"\n"+parseInt('abc12'));
*/
alert(parseInt('09'));
</script>