Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Confused about JSON and Array in TypeScript

$
0
0

I get data from the database with Sveltekit and nodejs and always fetching data like that

...responseData = await response.json();

It returns Object and I can assign it to an array

let getData = [];getData = responseData ;

What makes me confused is why the returned JSON Object display at console have the bracket which should be an array.(but it is Object checking with typeof)

[ {a:1,b:1}, {a:2,b:2},]

What i expect of a JSON Object should look like{"name":"John", "age":30, "car":null}

and why the JSON Object can be assigned to an array directly?

I guess I have some misunderstanding about these data types.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>