-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-4-1.html
43 lines (41 loc) · 1.1 KB
/
5-4-1.html
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
<!DOCTYPE html>
<script>
var MYAPP = MYAPP || {};
MYAPP.namespace = function(ns_string) {
var parts = ns_string.split('.'),
parent = MYAPP,
i;
if (parts[0] === 'MYAPP') {
parts = parts.slice(1);
}
for (i = 0; i < parts.length; i++) {
if (typeof parent[parts[i]] === 'undefined') {
parent[parts[i]] = {};
}
parent = parent[parts[i]];
}
return parent;
};
MYAPP.namespace('MYAPP.utils.array');
MYAPP.utils.array = (function() {
var uobj = MYAPP.utils.object,
ulang = MYAPP.utils.lang,
array_string = '[object Array]',
ops = Object.prototype.toString,
inArray = function(needle, haystack) {
for (var i = 0, len = haystack.length; i < len; i += 1) {
if (haystack[i] === needle) {
return true;
}
}
},
isArray = function(a) {
return ops.call(a) === array_string;
};
return {
isArray: isArray,
indexOf: inArray
};
}());
alert(MYAPP.utils.array.isArray([1, 2]));
</script>