Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: xyjax-field-obtainer
node v10.24.1
endpoint
share
tweet
const { obtainField } = require('xyjax-field-obtainer') const target = {a: {b: 2}, c: 5} const a_field = obtainField(target, 'a') console.log(a_field) // {b: 2} const a_b_field = obtainField(target, 'a.b') console.log(a_b_field) // 2 const c_field = obtainField(target, 'c') console.log(c_field) // 5 const not_existing_field = obtainField(target, 'd') console.log(c_field) // undefined const not_existing_nested_field = obtainField(target, 'd.e.f') console.log(not_existing_nested_field) //undefined
Created from: https://npm.runkit.com/xyjax-field-obtainer
Loading…
Clone and edit this document