Accessing any string type element inserted within multiple arrays

Advertisements

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?

>Solution :

You can use toString function for that

console.log([[["a"]]].toString());

Leave a Reply Cancel reply