prop() function
オブジェクトからプロパティの値を取得します。プロパティがオブジェクトに存在しない場合は undefined を返します。
Signature:
typescript
declare function prop<K extends Key, T>(key: K, obj: T): Prop<T, K>;Example
ts
// get the `name` property from an object
const person = { name: "John", age: 30 };
const name = prop("name", person); // "John"
// with pipe
pipe(person, prop("name"));
// get the `address` property from an object that may be null or undefined
const maybePerson = null;
const address = prop("address", maybePerson); // undefined