Why can we pass Number
, Boolean
or String
to an Array map but not RegExp? Could be something noob, but just trying to get my head around on the basic difference between these constructors?
let array = ["10", "20", "30", "40", "0"];
console.log("Boolean",array.map(Boolean));
console.log("Number",array.map(Number));
console.log("RegExp",array.map(x=>new RegExp(x)));
//cannot do array.map(RegExp)