I have an issue with ternary operation:
let a = undefined ? \"Defined!\" : \"Definitely Undefined\",
b = abc ? \"Defined!\" : \"Definitely Undefined\", // Re
What is the best and short way to check if abc is undefined before accessing its properties as well as assign blank object {} if undefined?
And you said that
I am currently using (typeof abc !== "undefined")
Looks like you have abc defined and the value is undefined
.
You can try doing
var a = abc || {};
console.log(a);