gugod
unread,Nov 16, 2008, 7:06:38 AM11/16/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to hsinchu.js
以下 keys 函式可以用來取得物件所有的屬性(property)名稱:
function keys(o) {
var r = [];
for(var a in o) { r.push(a); }
return r;
}
使用方法如:
pet = {
"nick": "little black",
"age": 3,
"type": "cat"
};
properties = keys(pet); // [ "nick", "age", "type" ]