i have a JSON object that gets returned by an AJAX request and I am having some trouble with the .length
because it keeps returning undefined
. Just wondering if I'm using it right:
console.log(data.length);
console.log(data.phones.length);
They both return undefined
even though they are valid objects.
Update:
Sample of the JSON object returned:
{"reqStatus":true,"phones":{"one":{"number":"XXXXXXXXXX","type":"mobile"},"two":{"number":"XXXXXXXXXX","type":"mobile"}}}
.lenght
instead of.length
and typescript interpreter never complained. Welcome to scripting world! – Disendow