Проблема в том, у вас не объявленный переменные ... вы должны поставить эту первые: var a = {};
. Но вот как я проверяю подобные вещи.
var utils = {
//Check types
isArray: function(x) {
return Object.prototype.toString.call(x) == "[object Array]";
},
isObject: function(x) {
return Object.prototype.toString.call(x) == "[object Object]";
},
isString: function(x) {
return Object.prototype.toString.call(x) == "[object String]";
},
isNumber: function(x) {
return Object.prototype.toString.call(x) == "[object Number]";
},
isFunction: function(x) {
return Object.prototype.toString.call(x) == "[object Function]";
}
}
var a = ""; // Define first, this is your real problem.
if(!utils.isObject(a)) {
// something here.
}
Вы должны определить 'Ā' где-то, прежде чем руки. Возможно, в самом внешнем виде, если вы хотите, чтобы он вел себя как глобальный. –
@Jamen Я нашел решение: http://stackoverflow.com/a/32247052/22470 – powtac