Iterator function array var _array array var _current this setArray fu

 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
Iterator = function(array) {
var _array = array;
var _current = 0;
this.setArray = function(array) {
_array = array;
if (_current > (_array.length - 1)) {
_current = _array.length;
}
};
this.get = function() {
return _array[_current];
};
this.current = function() {
return _current;
};
this.next = function() {
return (_current != (_array.length - 1)) ? _current++ : false;
};
this.prev = function() {
return (_current != 0) ? _current-- : false;
};
this.reset = function() {
_current = arguments[0] ? parseInt(arguments[0]) : 0;
};
this.slice = function(from /*, to*/) {
return _array.slice(from, arguments[1]);
};
};