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( )
今日 33.33%
本周 71.43%
本月 96.77%
本年 41.10%
Powered by Snowinlu | Copyright © 2024- | MIT License