When I double click on the cell of an ExtJs grid returns the uuid but when selecting the button I return the object as such.
How can I know if what returns to me is a string or an object?
In javascript the safest way to know if it is an object of type x you can do it with Object.prototype.toString
since it will give you a result like [object Tipo]
.
This solution may not work for the object because it can return [object Object]
or something else depending on how they have implemented it.
If it will work for strings
since it will always return [object String]
so you can use the following function.
function isString(obj) {
return Object.prototype.toString.call(obj) === '[object String]';
}
You can use typeof
as well but I do not recommend it since
console.log(typeof 'sdas'); => string
console.log(typeof new String('sdas')); => object