Access data from Array

Asked

Viewed 44 times

0

I have an Array that has the following items:

[[362, SCAB171570FEC]]

To display this I use the following expression:

return $data.listaItensPedido.value;

But I need for example to access only the 362, tried that expression:

return $data.listaItensPedido.value[0];

And so I was not returned anything. It is possible to access each item of this array?

  • The code is incomplete. what happens until you arrive at $data.listaItensPedido.value?

  • Forehead return $data.listaItensPedido.value[0][0];. If you don’t give what appears in console.log(typeof $data.listaItensPedido.value);?

  • @Sergio return $data.listaItensPedido.value[0][0]; did not return me anything, I tried to put return (typeof $data.listaItensPedido.value); and you were shown this: string

  • 1

    In this case this value is a string, you have to convert from JSON in string to object format. Test: return JSON.parse($data.listaItensPedido.value)[0][0];

  • @Sergio put this on and I was not shown anything

  • :/ What gives console.log(typeof $data.listaItensPedido.value, $data.listaItensPedido.value);?

  • @Sergio put this return (typeof $data.listaItensPedido.value, $data.listaItensPedido.value); and returned this to me: [[362, SCAB171570FEC]]

  • @Sergio console.log(typeof $data.listaItensPedido.value, $data.listaItensPedido.value); showed me this on the console $data.listaItensPedido is undefined

  • @Lucascosta as well as "what happens"?

  • The complete chunk of the code, the form that this variable is populated @R.Santos

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.