Skip to content

isPlainObject

与えられた値がプレーンオブジェクトであるかどうかを確認します。

インターフェース

typescript
function isPlainObject(object: object): boolean;

パラメータ

  • object (object): 検査する値。

戻り値

(boolean): 値がプレーンオブジェクトの場合はtrue。

typescript
console.log(isPlainObject({})); // true
console.log(isPlainObject([])); // false
console.log(isPlainObject(null)); // false
console.log(isPlainObject(Object.create(null))); // true
console.log(Buffer.from('hello, world')); // false

パフォーマンス比較

Bundle SizePerformance
es-toolkit279 bytes (82.4% smaller)1,505,684 times (1.70× faster)
es-toolkit/compat435 bytes (72.5% smaller)2,013,760 times (2.28× faster)
lodash-es1,586 bytes882,669 times

MIT ライセンスの下で配布されています。