Цитата:
['mouseover', 'mouseout', 'mousemove', 'mousedown', 'mouseup', 'click'].join().search('mousemove') === -1;
//либо так:
'mouseover, mouseout, mousemove, mousedown, mouseup, click'.search('mousemove') === -1;
для тех, кто не знает как реализовать Array.indexOf():
(function($) {
if(!$.indexOf) {
$.indexOf = function(object) {
var length = this.length -1, i = 0;
while(++i <= length) {
if(i in this && this[i] === object) {
return i;
}
}
return -1;
};
}
})(Array.prototype);
Shock, у вас все проекты ориентированные на IE9+? DNemo/DreamTheater, что за событие mouseclick? |
Цитата:
|
Цитата:
|
Цитата:
1. по прежнему lastIndexOf. 2. возможен бесконечный цикл (если массив пустой). 3. никогда не находит совпадение в последнем элементе ( alert([2, 1].indexOf(1));// -1 ). Без поддержки второго аргумента (from) у меня получается так:
if (!('indexOf' in arrayProto)) {
arrayProto.indexOf = function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] === item) return i;
}
return -1;
};
}
|
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
(function($) {
if(!$.indexOf) {
$.indexOf = function(object) {
var length = this.length, i = arguments[1] || 0;
i = Math[i < 0 ? 'ceil' : 'floor'](i) - 1;
//для отрицательных индексов
if(i < 0) i += length;
while(++i <= length) {
if(i in this && this[i] === object) {
return i;
}
}
return -1;
};
}
})(Array.prototype);
|
| Часовой пояс GMT +3, время: 02:17. |