Introduction: This is the third article in the new series about the nice parts of Java Script. Its about different ways to access variables:
// 1. undefined values cannot be easily accessed in JS
// this would cause: "ReferenceError: "unknownVariable" is not defined
// if (!unknownVariable) {
// console.log("No value");
// }
// 2. but we can use "in"
if ("unknownVariable" in this) {
console.log("The variable 'unknownVariable' exists in the current scope - don't know the value though");
}
// 3. combined
if (!"unknownVariable" in this || !this["unknownVariable"]) {
console.log("No value");
}