Skip to content

js 中类型的校验

js
const isEmpty = (val) => {
  val == null || !(Object.keys(val) || val).length;
};
js
const isArray = (val) => {
  if (typeof Array.isArray === "undefined") {
    return Object.prototype.toString.call(val) === "[object Array]";
  }
  return Array.isArray(val);
};
2025( )
今日 25.00%
本周 14.29%
本月 54.84%
本年 20.82%
Powered by Snowinlu | Copyright © 2024- | MIT License