-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
96 lines (81 loc) · 1.75 KB
/
test.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
95
96
var fn;
function foo() {
var a = 2;
function baz() {
console.log(a)
}
fn = baz;
}
function bar() {
fn();
}
foo();
bar();
function wait(message) {
setTimeout(function timer() {
console.log(message);
}, 1000);
}
wait("Hello, closure!");
/*
function setupBot(name, selector) {
$( selector ).click( function activator() {
console.log( "Activating: " + name );
});
}
setupBot ( "Closure Bot 1", "#bot_1" );
setupBot ( "Closure Bot 2", "#bot_2" );
*/
for (let i = 1; i <= 5; i++) {
let j = i;
setTimeout( function timer(){
console.log( j );
}, j * 1000);
}
function CoolModule() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( "!"));
}
return {
doSomething: doSomething,
doAnother: doAnother
};
}
var foo2 = CoolModule();
foo2.doSomething();
foo2.doAnother();
var myObject = {};
Object.defineProperty(
myObject,
"a",
{ enumerable: true, value: 2 }
);
Object.defineProperty(
myObject,
"b",
{ enumerable: false, value: 3 }
);
console.log( myObject.b );
console.log( ("b" in myObject) );
console.log( myObject.hasOwnProperty( "b" ) );
for ( var k in myObject) {
console.log( k, myObject[k] );
}
console.log( myObject.propertyIsEnumerable( "a" ) );
console.log( myObject.propertyIsEnumerable( "b" ) );
console.log( Object.keys(myObject) );
console.log( Object.getOwnPropertyNames(myObject) );
var myArray = [1, 2, 3];
for (var v of myArray) {
console.log( v );
}
var it = myArray[ Symbol.iterator ] ();
console.log( it.next() );
console.log( it.next() );
console.log( it.next() );
console.log( it.next() );