S
S
sergey_from_saratov2017-10-27 01:21:52
JavaScript
sergey_from_saratov, 2017-10-27 01:21:52

Why is the result of JSON.stringify an empty array?

Why https://jsfiddle.net/zLtm6y2d/ in console.log(JSON.stringify(result)); the result is an empty array, and if you replace it with console.log(result); then a normal array with data?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-27
@sergey_from_saratov

Well, result is an array, and the keys of the properties added to it are not numeric - accordingly, they are discarded when converted to a string.
Declare result as an object - var result = {};- and you'll be fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question