0

I suffer for three hours already, trying to bring array from something like this:

var mltDim = [/1/, /2/, [/31/, [/321/, /322/, /323/], /33/], /4/, [/51/, /52/], /6/];

into this:

var oneDim = [/1/, /2/, /31/, /321/, /322/, /323/, /33/, /4/, /51/, /52/, /6/];

The additional problem is to make recursive function, because depth of array will not be defined.
All non-Array values will definitely be RegExps, so you may count on it. Non-RegExp values will be filtered out.


P.S.: Solving this problem, I wrote own typeOf() function:

var typeOf = obj => obj? obj.constructor.toString().match(/.{9}(\w+)(?=\()/)[1] : "Undefined";

I'll use it for defining type of given objects.

Dima Parzhitsky
  • 3,716
  • 2
  • 20
  • 37

0 Answers0