For javascript data types you can use typeof: console.log(typeof attrs[key]);
These are some common types that will be returned:
- null,
- undefined,
- object,
- boolean,
- number,
- string,
- function
質問
The code below will enumerate properties of an object, but can the data types be enumerated?
function enumerateAttributes(node){
var text="";
var attrs=circle1.getAttrs();
for (key in attrs) {
if (attrs.hasOwnProperty(key)) {
text+=(key+"=="+attrs[key]+"\n");
}
}
alert(text);
}
解決
For javascript data types you can use typeof: console.log(typeof attrs[key]);
These are some common types that will be returned: