Home > database >  Accessing any string type element inserted within multiple arrays
Accessing any string type element inserted within multiple arrays

Time:11-07

Suppose I have an array:

let x = [[["3"]]];

I can access easily to the inserted element without using object notation by simply writing

parseInt(x); // 3

But if we

let x = [[["a"]]];

There is no number within multiple arrays in x, so how can we access ("a") directly in one step, like parseInt() for above situation. Is there any way, then suggest?

CodePudding user response:

You can use toString function for that

console.log([[["a"]]].toString());
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

x[0]=[["a"]]

x[0][0]=["a"]

So you want

x[0][0][0]
  • Related