=== null && console.log("null");
Array.isArray(val) && console.log("array/object");
if (val !== null) {
const x = val.toString();
const rule = new RegExp(/[0-9]./g);
return rule.test(val)
? console.log("intiger")
: console.log(typeof val);
}
};
intiger
it gonna print array/object object for arrays
Wtf
Avoid new RegExp, use literal instead where possible
This is better: https://github.com/ramda/ramda/blob/master/source/type.js
Обсуждают сегодня