-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.js
94 lines (78 loc) · 1.25 KB
/
temp.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
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
var a = 12;
foo();
function foo(){
a = 432;
console.log(a);
var a;
}
console.log('Value outside');
console.log(a);
function scopeTest(){
var a = 123;
if(a > 120){
var b = 10;
while(b > 5){
b--;
var c = a * b;
console.log(c);
}
console.log('all done');
console.log(c);
}
console.log('Now its the turn of b');
console.log(b);
}
scopeTest();
function scopeTest(){
var a = 123;
if(a > 120){
let b = 10;
while(b > 5){
b--;
let c = a * b;
console.log(c);
}
console.log('all done');
console.log(c);
}
console.log('Now its the turn of b');
console.log(b);
}
scopeTest();
function User(){
var username,password;
function login(user, key){
username = user;
password = key;
console.log('User is trying to log in with username ' + username);
console.log('And the password is *********');
}
function nextMethod(){
console.log('I still hold '+ username);
}
var returnObject = {
doLogin: login,
nextStep: nextMethod
};
return returnObject;
}
var x = User();
x.doLogin('good','bad');
x.nextStep();
(function(){
"use strict"
function foo(){
console.log(this.bar);
}
var bar = "hello global";
var obj1 = {
bar: "obj1",
foo: foo
}
var obj2 = {
bar: "bar2"
}
foo();
obj1.foo();
foo.call(obj2);
new foo();})();