This address:http://www.cnblogs.com/veinyin/p/7944072.html
Correct format
1 Let json = { 2 ' 0 ': ' waaaa~ ', 3 ' 1 ': ' Hello, ', 4
' 2 ': ' world! ' , 5 Length:3 6} 7 8 Let arr = array.from (JSON); 9 Ten Console.log (arr);
Effect of conversion
The conversion must be a JSON array format, if there is no length in the JSON, then the converted array is an empty array
Comment out the result of line 5th above
Since the Json key is converted to the subscript of the array, you have to be aware of this , and here are a few things that could make the value of the array undefined
1 key cannot be turned into subscript
1 Let json = { 2 ' a ': ' waaaa~ ', 3 ' B ': ' Hello, ', 4
' C ': ' world! ' , 5 Length:3 6} 7 8 Let arr = array.from (JSON); 9 Ten Console.log (arr);
2 key greater than or equal to length causes overflow
1 Let json = { 2 ' 0 ': ' waaaa~ ', 3 ' 1 ': ' Hello, ', 4
' 3 ': ' world! ' , 5 Length:3 6} 7 8 Let arr = array.from (JSON); 9 Ten Console.log (arr);
Because Arr[2] did not give the value, so gave the undefined, even give arr[3] the value is world! , but I can only get the array to arr[2], so I can't see world! This item
3 is not defined as above.
1 Let json = { 2 ' 0 ': ' waaaa~ ', 3 ' 1 ': ' Hello, ', 4
' 3 ': ' world! ' , 5 Length:5 6} 7 8 Let arr = array.from (JSON); 9 Ten Console.log (arr);
This time the length of the big point, you can see if not given is undefined
Ah ah ah ah, the feeling is not clear, anyway, is equivalent to the assignment, the preceding key is the index value, followed by the value of the corresponding array element, length is the size of the array, that's it.
End~~~≥ω≤
ES6 Array.from () cannot get an array element that is undefined or an empty array