|
|
От: |
Mamut
|
http://dmitriid.com |
| Дата: | 10.08.07 14:27 | ||
| Оценка: | |||
inArray: function( b, a ) {
for ( var i = 0, al = a.length; i < al; i++ )
if ( a[i] == b )
return i;
return -1;
},
each: function( obj, fn, args ) {
if ( obj.length == undefined )
for ( var i in obj )
fn.apply( obj[i], args || [i, obj[i]] );
else
for ( var i = 0, ol = obj.length; i < ol; i++ )
if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
return obj;
} // This may seem like some crazy code, but trust me when I say that this
// is the only cross-browser way to do this. --John
isFunction: function( fn ) {
return !!fn && typeof fn != "string" && !fn.nodeName &&
fn.constructor != Array && /function/i.test( fn + "" );
}Z>var a, b, c;
Z>a = /^\dfunction\d/;
Z>b = new String('Wow, J(ava)Script is soooo functional...');
Z>c = ['method', 'function', 'object'];
Z>c.constructor = 'Lego';
Z>A regular expression pattern is converted into an internal function using the process described below.
Паттерн регулярного выражения конвертируется во внутреннюю функцию используя описанный процесс.
A Pattern evaluates ("compiles") to an internal function value. RegExp.prototype.exec can then apply this function to a string ...
Паттерн вычисляется ("компилирутся") во внутренне функциональное значение. RegExp.prototype.exec может потом применить эту функцию к строковому литералу...