Object Has Key

Check if an object has a specific key using dot notation for nested paths.

Code

General
path.split('.').reduce((acc, key) => acc && acc[key] !== undefined ? acc[key] : undefined, obj) !== undefined;

Parameters

Object to check

Key path (dot notation)

Browser·fetch() may be limited by CORS

More JavaScript Snippets