Last active
June 8, 2018 04:10
-
-
Save vibhasbhingarde/a8a71f24fc832f1f77e912e2cd944295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if nested property exists or not | |
var propertyexists = (objectname,path) => path.split(".").reduce((k,v) => (typeof k=="undefined")?k:k[v],objectname); | |
var myobject = {info:{name:"vibhas"}}; | |
console.log(propertyexists(myobject,"info.name.jhgfdsa.asdfghj")); | |
// If exists it return that value or "undefined" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment