![]() If you pass a default value, _.get() will return the default value where it would normally return undefined. The third argument to _.get() is the default value. Type = _.get( null, '') // undefined Default Values Type = _.get(landmark, '') // undefined // Even if `landmark` is `null`, `_.get()` does not error out. `_.get()` doesn't error out, even though `landmark.location` is // undefined. let type = _.get(landmark, '') // 'Point' delete landmark.location The _.get() function lets you safely access the nested property, without having to explicity check whether landmark, landmark.location, or is undefined. TypeError: Cannot read property 'geometry' of undefined Intermediate property is null or undefined. Get deeply nested properties in an object without worrying about whether an
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |