Lodash - isEmpty 方法



語法

_.isEmpty(value)

檢查值是否為空物件、容器、對映或集合。

引數

  • value (*) − 要檢查的值。

輸出

  • (boolean) − 如果值為空,則返回 true,否則返回 false。

示例

var _ = require('lodash');
console.log(_.isEmpty(1));
console.log(_.isEmpty([1, 2, 3]));

將以上程式儲存在 tester.js 中。執行以下命令以執行此程式。

命令

\>node tester.js

輸出

true
false
lodash_lang.htm
廣告
© . All rights reserved.