1

[2]などのエントリを下から削除するにはどうすればよいですか?

var object = {};
object[0] = true;
object[1] = true;
object[2] = true;
4

2 に答える 2

6

This will work:

delete object["2"]

I would suggest you don't use "object" as your variable name. "object" is a reserved word.

Also, see this question: how-to-remove-a-property-from-a-javascript-object

EDIT:

Actually "object" is not on the list of reserved words. But "Object" (capital "O") does have a meaning in JavaScript. So I would discourage using that name anyway.

于 2012-11-01T11:17:25.703 に答える
1

To remove object properties, use delete, like this:

delete object[2];
于 2012-11-01T11:17:47.613 に答える