Loading topic
?.) and nullish coalescing (??) both react to the same small set of values. Before you use either operator, you need to know exactly which values those are and how they differ from the broader group JavaScript calls "falsy."2 min read|| and &&, and that you have read the previous chapter on nullish values. It explains why the long-standing value || fallback idiom replaces values you meant to keep. The next chapter introduces the operator that fixes 2 min read|| picks its result. Earlier chapters showed that null and undefined are the only nullish values, and that || replaces every falsy value, including 0 and "". Here you will learn how the nullish coalescing operator ?? fixes t2 min readnull and undefined differ from other falsy values (covered in "What Counts as Nullish"). It covers the dot form of optional chaining, ?.. The bracket and call forms come in the next two chapters.2 min readobj[key]), arrays and their indexes, and the basic ?. operator from the previous chapter. The dot form obj?.name only works when you can type the property name in your code. When the key is stored in a variable, computed at runtime, or is 2 min readthis works in a method call, and how ?. guards property access from the previous chapters.2 min read?. returns undefined when the value to its left is null or undefined, and that ?? replaces only null and undefined. Here you put the two together to read deeply nested data and supply a fallback2 min read?. works for property access, bracket access and calls, as covered in earlier chapters. It also assumes you are comfortable with JavaScript expressions that have side effects, such as count++ or a function call that logs output.2 min read?? chooses a fallback and how || treats every falsy value as missing. Here you will learn the assignment form, ??=, which writes a default into a variable or property only when the current value is null or undefined.2 min read?? supplies defaults for null and undefined, how || and && short-circuit, and what operator precedence means: the rule that decides which operator grabs its operands first when an expression has no parentheses.2 min read?., ?.[] and ?.() work, and how an optional chain short-circuits when it reaches null or undefined. It covers where the language rejects optional chaining, and the cases where ?. gives you no protection.2 min read?., ?? and ??= behave, including how chains short-circuit. The question here is a judgment call: when does reaching for them make your code worse?2 min read?., ?? and ??= from earlier chapters. It also assumes you have a basic idea of what a build tool or transpiler does. A transpiler is a tool that rewrites modern JavaScript into older syntax. The question here is practical: where can you use these ope3 min read