You could always use something like this for the last one (fairly sure I did something similar in PHP before this was an option):
function get(obj, path=[], fallback=null, separator="."){ if(path.constructor === String){ path = path.split(separator); } return path.reduce( (r, k) => r[k] || fallback, obj ); } /** # Examples const convolutedObject = {a:1,b:{a:2,b:{a:3,b:{a:4,b:5}}}}; get(convolutedObject, ["b","c"], "wrong"); // "wrong" get(convolutedObject, "b.b.b.a"); // 4 */
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You could always use something like this for the last one (fairly sure I did something similar in PHP before this was an option):