-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhat.js
65 lines (65 loc) · 1.54 KB
/
what.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
Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi)
a = ["anne", "bob", "charles", "daniel", "ecstasy"];
["anne", "bob", "charles", "daniel", "ecstasy"]
a;
["anne", "bob", "charles", "daniel", "ecstasy"]
a[4];
"ecstasy"
a[4];
"ecstasy"
a[3];
"daniel"
a[2];
"charles"
a[1];
"bob"
a[1] = "bitch";
"bitch"
a;
["anne", "bitch", "charles", "daniel", "ecstasy"]
temp = a[2];
"charles"
a[3] = temp;
"charles"
a[2] = a[3];
"charles"
a;
["anne", "bitch", "charles", "charles", "ecstasy"]
a = ["anne", "bob", "charles", "daniel", "ecstasy"];
["anne", "bob", "charles", "daniel", "ecstasy"]
a;
["anne", "bob", "charles", "daniel", "ecstasy"]
temp = a[2];
"charles"
a;
["anne", "bob", "charles", "daniel", "ecstasy"]
temp;
"charles"
a[2];
"charles"
a[2] = a[3];
"daniel"
a;
["anne", "bob", "daniel", "daniel", "ecstasy"]
a[3] = temp;
"charles"
a;
["anne", "bob", "daniel", "charles", "ecstasy"]
swap(2,3);
ReferenceError: swap is not defined
swap = function(a, i, j) { var temp = a[i]; a[i] = a[j]; a[j] = temp; }
function (a, i, j) { var temp = a[i]; a[i] = a[j]; a[j] = temp; }
a;
["anne", "bob", "daniel", "charles", "ecstasy"]
swap(a, 0, 1);
undefined
a;
["bob", "anne", "daniel", "charles", "ecstasy"]
swap(a, 0, 1);
undefined
a;
["anne", "bob", "daniel", "charles", "ecstasy"]
swap(a, 3, 1);
undefined
a;
["anne", "charles", "daniel", "bob", "ecstasy"]