yeah seems weird but I guess this is the reason why it works: "When using the JSON.parse() on a JSON derived from an array, the method will return a JavaScript array, instead of a JavaScript object."
Okay, I now also tested C. And I have to admit that this should be the correct answer.
I didn't expect this at first because the string "[1, 2, 3, 4]" is not in Javascript Object Notation, like '{ "name":"James", "age":34, "city":"Jamestown"}'.
Below you can see my test code:
<script>
var objStr = "[1, 2, 3, 4]";
var json = JSON.parse(objStr);
for (var i in json) {
alert(json[i]);
}
</script>
Therefore you could use the following JavaScript:
<script src="../jquery.js"></script>
<script>
window.onload = function () {
var objStr = "[1, 2, 3, 4]";
var jsObject = $.makeArray(objStr.replace("[", "").replace("]", "").split(", "));
alert($.isArray("jsObject is array: " + jsObject));
for (var i in jsObject) {
alert(jsObject[i]);
}
}
</script>
upvoted 1 times
...
...
...
This section is not available anymore. Please use the main Exam Page.70-480 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
AnetteK
4 years, 5 months agoBart_v_M
4 years, 6 months agoBart_v_M
4 years, 6 months agoBart_v_M
4 years, 6 months agoBart_v_M
4 years, 6 months ago