first commit
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
引数が空か
|
||||
|
||||
判定基準
|
||||
文字列
|
||||
長さが0の場合
|
||||
配列
|
||||
長さが0の場合
|
||||
オブジェクト
|
||||
keyが存在しない場合
|
||||
それ以外
|
||||
常にfalse
|
||||
*/
|
||||
function isEmpty(arg){
|
||||
if(typeof arg==='string'){
|
||||
return !arg.length;
|
||||
}else if( Array.isArray(arg) ){
|
||||
return !arg.length;
|
||||
}else if(typeof arg==='object' && arg instanceof Object){
|
||||
return !Object.getOwnPropertyNames(arg).length;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default isEmpty;
|
||||
Reference in New Issue
Block a user