-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-4-3.html
60 lines (55 loc) · 1.17 KB
/
5-4-3.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!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 += 1){
if(typeof parent[parts[i]] === 'undefined'){
parent[parts[i]] = {};
}
parent = parent[parts[i]];
}
return parent;
};
MYAPP.namespace('MYAPP.utils.array');
MYAPP.utils.Array = (function(app, global){
var uobj = MYAPP.utils.object,
ulang = MYAPP.utils.lang,
array_string = '[object Array]',
ops = Object.prototype.toString,
Constr;
// public constructor
Constr = function(o){
this.elements = this.toArray(o);
};
Constr.prototype = {
toArray : function(obj){
for(var i = 0, len = obj.length, a = []; i < len ; i += 1){
a[i] = obj[i];
}
return a;
},
isArray : function(){
return ops.call(this.elements) === array_string;
},
inArray : function(a){
for(var i = 0, len = this.elements.length ; i < len ; i += 1){
if(this.elements[i] === a){
return i;
}
}
return -1;
}
};
return Constr;
}(MYAPP, this));
var ary = new MYAPP.utils.Array([1,2]);
alert(ary.isArray());
//-->
</script>