Lodash get vs. es6 fallback values?
For the latest browsers, or by using polyfills or transpiler, you could also use optional chaining and nullish coalescing operator like:
latitude: response?.pickupLocation?.latitude ?? ''
The advantage of _.get
is, you omit continuing checks if a property exist, which would be necessary.
latitude: response && response.pickupLocation && response.pickupLocation.latitude || "",