0

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?

DecPK
  • 24,537
  • 6
  • 26
  • 42
  • 1
    `x.flat(Infinity)[0]`? Familiarize yourself with [how to access and process nested objects, arrays or JSON](/q/11922383/4642212) and use the available static and instance methods of [`Array`](//developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array#Static_methods). – Sebastian Simon Nov 07 '21 at 08:26

2 Answers2

0

You can use toString function for that

console.log([[["a"]]].toString());
Vineesh
  • 3,762
  • 20
  • 37
0
x[0]=[["a"]]

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

So you want

x[0][0][0]
blackgreen
  • 34,072
  • 23
  • 111
  • 129
dave110022
  • 64
  • 5