exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 1 question 174 discussion

Actual exam question from Microsoft's 70-486
Question #: 174
Topic #: 1
[All 70-486 Questions]

You develop a new ASP.NET MVC application. You use local storage to maintain state.
The localStorage object's setItem method is failing to store a value.
Which two scenarios will cause the failure? Each correct answer presents a complete solution.
NOTE: Each correct selection is worth one point.

  • A. The user has disabled local storage in the browser.
  • B. The value being stored is a JavaScript array.
  • C. The new Value property was used prior to calling the setItem method.
  • D. The value being stored exceeds 10MB in size.
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️
References:
https://www.w3schools.com/html/html5_webstorage.asp
https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
[Removed]
Highly Voted 5 years, 8 months ago
Correct answer is A,D
upvoted 17 times
...
AsaGuo
Highly Voted 5 years, 9 months ago
AD. Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded. https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem
upvoted 11 times
...
GG007
Most Recent 4 years, 5 months ago
Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.) Based on this statement, the correct answer is A & D options!
upvoted 1 times
...
ewdlop
4 years, 10 months ago
The value being stored exceeds 10MB in size. not the local quota. I think it was asking the operation, not the result of the operation
upvoted 1 times
...
Jobair
5 years ago
Question is `setItem method is failing to store a value`. it's just one value not all of them. So, I guess B & C are correct
upvoted 1 times
...
tanujgyan
5 years, 1 month ago
A D are correct
upvoted 4 times
...
Dhaval
5 years, 4 months ago
Correct answer is A,D
upvoted 4 times
...
Smartiup
5 years, 5 months ago
Correct answer is A,D. A - If the user disables local storage, client side code will not be able to set an item in local storage. D - Local storage item can store a maximum of 5mb, so 10mb would be to much and make it fail in the setitem.
upvoted 10 times
mr_
5 years ago
I would go for the same answers (A & D) but: * Local storage does not need to have quota of 5 mb - it is configurable, similar way as disabling/enabling local storage in the browser. It can be set to unlimited actually. What is more the quota can differ from browser to browser. So if the quota of 10mb is exceed then yes - setting the value in local storage would fail but who said it is 10 megs or less here? So this answer is really slick I would say; * Local storage accepts only strings so in order to store JS array it has to be serialized somehow (e.g. to JSON). Storing JS array would fail as well, wouldn't it?
upvoted 1 times
mr_
5 years ago
A & D seem to be the most probable correct answers. I tested setting JS array and it works out of the box, without need of serializing it in the code manually even though local storage can still store only string values. JS array is serialized automatically to the string like: 'valueIndex0,valueIndex1,valueIndex2'.
upvoted 3 times
...
...
...
Aghie
5 years, 10 months ago
Based from this: https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem Creating a new key/value pair if none existed for key previously. Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded. So the answers are AC
upvoted 3 times
founderDev
5 years, 4 months ago
Correct answer is A,D.
upvoted 9 times
...
...
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.

SaveCancel
Loading ...