how to check how many [] symbols array contain

So, I have an array like this
const array=[1,2,3,4,[5,6],[[[[7,8]]]]]. I know that I can make it flat by flat function like this.
array.flat(4) // [1,2,3,4,5,6,7,8]

But as you know we can to this when we know array external count of this [] symbols. However we can fetch
any data that we don’t know how many [] this symbols are there in array. My question is that how to check
how many [] – this symbols are there within array.