Flatten an array using spread or rest operator [duplicate]

  ecmascript-6, javascript

Is there a way to flatten the below array using spread or rest operator in javascript

var a = [1, 2, 3, [1, 2, 3], 1, 2,3, [1, 2, 3]];

Desired output is [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];

Tia

Source: Ask Javascript Questions

LEAVE A COMMENT