Skip to content

Instantly share code, notes, and snippets.

@semicolon
Created August 31, 2015 13:04
Show Gist options
  • Save semicolon/3520ea9ae8fe6b46ffc8 to your computer and use it in GitHub Desktop.
Save semicolon/3520ea9ae8fe6b46ffc8 to your computer and use it in GitHub Desktop.
IE8 で Object の要素数を取得する
var obj = {
"key0": "val0",
"key1": "val1",
"key2": "val2",
}
/*
以下は IE8 で動かない
var len = Object.keys(obj).length;
*/
//一度ループさせて数を取得する必要がある
var len = 0;
for (key in obj) {
len++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment