Home >Web Front-end >JS Tutorial >Abominable ie8 prompts that the id is missing and is undefined_javascript tips

Abominable ie8 prompts that the id is missing and is undefined_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:55:021077browse

Recently I have been programming in javascript, using json, and wrote an array [{'id':'key_01','name':'university'},{'id':'key_02','name':'direct card' },{'id':'key_03','name':'new'},{'id':'key_04','name':'Change'},{'id':'key_05','name ':'M-Zone Card Set'},{'id':'key_06','name':'Inventory'},{'id':'key_07','name':'Fetion'},{'id': 'key_08','name':'Mobile Video'},{'id':'key_09','name':'School Communication'},];

Add to select in a loop on the page , but in IE8, it always prompts that the missing id is undefined, and it is ok in other browsers. Later, I used IE8's js debugging and found that the length of his array is 1 larger than the length of the array in other browsers, but the actual view The array does not have that many values. Later, when I looked carefully, I found that there was an extra comma at the end of the array. Just remove the comma.

It turns out that IE8 has a different method for obtaining the actual value and length. You cannot add extra commas at the end of the array.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn