LoginSignup
1
2

More than 5 years have passed since last update.

javascriptによるnotEmpty関数

Posted at
function notEmpty(value) {
    var result;
    switch (typeof value) {
    case 'string':
        // 文字の0を除く
        result = (value && value != 0);
        break;
    case 'object':
        // 配列の中身の数チェック
        result = (value && Object.keys(value).length);
        break;
    default:
        result = value;
    }
    return Boolean(result);
}

引用
http://qiita.com/sibusuke/items/d95275c89a623b805441

1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2