判断函数入参值是否为空,只能用于字符型(string)、对象(object)、数组(array)不适用于数值型和布尔型,举例说明:
1、空值: null、‘’、undefined 返回都是true 。Ex:
_.isEmpty(null) , _.isEmpty('') , _.isEmpty(undefined) 判断结果都是true
2、boolean类型 true、false 返回都是true 。Ex:
_.isEmpty(true) , _.isEmpty(false) 判断结果都是true
_.isEmpty('true') , _.isEmpty('false') 将参数视为字符串判断结果都是false
3、number类型 0、1、2 返回都是true。Ex:
_.isEmpty(0) , _.isEmpty(1) , _.isEmpty(2) 判断结果都是true
_.isEmpty('0') , _.isEmpty('1') , _.isEmpty('2') 判断结果都是false
扩展:JS _. 的函数使用参考网址 https://lodash.com/docs/4.17.5