|
|
От: | AKS. | |
| Дата: | 10.08.07 17:35 | ||
| Оценка: | 32 (1) | ||
a — функция
b — не функция
c — не функция
Что и следовало ожидать. Почему a — функция? Читаем ECMA-262...
var a, b, c;
a = /^\dfunction\d/;
b = new String('Wow, J(ava)Script is soooo functional...');
c = ['method', 'function', 'object'];
c.constructor = 'Lego';
// ...trust me... --John :)
function isFunction(fn) {
return !!fn && typeof fn != "string" && !fn.nodeName &&
fn.constructor != Array && /function/i.test( fn + "" );
};
alert([isFunction(a), isFunction(b), isFunction(c)]); // -> true, true, true!!!