? 2. ??? ?? ??? ??? ??? ??? 3. userData.email ?? = getDefaultEmail ()? ?? ??? ?? ??? ?? ? ? ??? ?? ?????. ? ???? 0, ''?? false? ?? ?? ?? ?? ?? ???, ?? || =?? ???? ?? ??? ???? ????? ????? ???? ???? ?? ???? ????.
Null Coalescing ?? ??? ( ??=
)? null
?? undefined
??? ???? ??? ??? ????? ? ????? ?? JavaScript (ES2021)? ?? ? ???? ??? ?????. ?? null
?? undefined
???? ???? ??? ????? ?? ?? ?????.

????? ??=
????? ?
??=
???? ??? ?? ?????.
a ?? = B;
??? ??? ?????.
" a
? null
??? undefined
?? b
a
? ??????. ??? ??? ???? a
??? ?? ????."

???? ?????.
if (a == null) { a = b; }
??? ?? ? ?? ?? ? ????.

? ?? :
??=
''
?null
??false
undefined
0
??? ??????.
???? ??=
1. ?? ?? ?? ?????
??? ?? ???? ?? ? ? ?? ??? ?? ? ???? ???? ????????.
?? createUser (??) { const user = {}; user.name = settings.name ?? '???'; user.age ?? = settings.age ?? 18; user.isActive ?? = settings.isActive ?? ??; ?? ???; }
?? ? ???? :
?? createUser (??) { const user = {?? : '??', ?? : 18, isactive : true}; user.name ?? = settings.name; user.age ?? = settings.age; user.isActive ?? = settings.isActive; ?? ???; }
??? ??? ? ?? ??? ????? undefined
?? ?? ?? ????.
2. ??? ??? ???
??? ?? ??=
?? ??? ?? ????? ?? ??? ? ????.
????; CACHE ?? = ??? HeaVyResource (); // ? ?? ?????
cache
??? null
? ?? ????? ??? ||=
? ?? ?? ??? ?? ? ? ????.
??
||=
? ??????.
||=
??? ? (0
,''
,false
?)? ????? ??? ??? ? ????.
??=
null
?undefined
???? ??? ?? ??? ?????.
3. ??? ?? ???? ??
?? ???? ?? ? ? ??=
?? ??? ???? ? ??????.
const userData = {id : 123, ?? : 'Alice'}; userData.email ?? = getDefaultEmail (userData.Name); userData.Role ?? = FetchDefaUltrole (); // ??? ?? ??
????? ??? ????? ? ??? ?? false
?? ???? ????.
?? ? : ?? ???
??? ?? { ??? () { this.apikey = null; this.timeout = 0; this.resries = false; } applyDefaults () { this.apikey ?? = process.env.api_key; this.timeout ?? = 5000; this.resries ?? = 3; } }
??:
-
timeout
?0
→0
?? ????? (???? ??) -
retries
false
→false
?? ????? - ???? ? ?? (
null
) ? ???? ????
? ??? ?? ???? ??? ??=
.
??? gotchas
- ?? ????? ??? ? ???? - ES2021 (Node.js 16, ?? ????)? ?????. Babel? ????? ??? ???? ??????.
- ?? ?? ??? ?? ?? ??? ?? ??? ?? ??? ??? ?? ?? ???? :
// ????? ???? ?? ???`=`? ???`=`? ????? const {name = 'default'} = obj; //??? ? ? ???? : {apikey} = obj??; Apikey ?? = 'Fallback-Key';
- ?? ?? : ???? ???
null
/undefined
???? ?????.
x = 1???; x ?? = console.log ( '??? ???? ??'); // ??? ????
??
?? ??=
?? :
-
null
/undefined
? ???? ???? ????????. -
0
,''
??false
?? ??? ?? ???????. - ??? ??? ?? ?? ???? ???? ????
????? ||=
? ?? - ?? ????.
??:
??=
= "??? ?? ? ???? ??"
||=
= "???? ??" - ?? ?? ??????
??=
?
? ??? Null Coalescing ?? ??? ?? (`?? =`)? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

== ?? === ??? PHP ?? ?? ??? ??? ?????. == == ??? ?? ??? ???? === ?? ??? ??? ???? ??? ??? ?????. ?? ??, 0 == "false"? true??? 0 === "false"? false??? 0 ? ??? ?? ?, ? ??? ?? ??? ?? ? ?? ??? ??? ???? ? ???????.

??? ????? regluceReadibility; useif-elsechainsinstead.2.don'tuseternariesforsideffects likefunctscalls; useif-elseforcontrolflow.3.skipternieswithcomplexpessionsinvollingLongStringsorlogic; breakthemintovariables.4.avoid

whenUllCoalescingOperator (??)? ?? hondlorUndefined.1.ItreturnsTheleftOperAndifitisnOtnullORundefined; ??? ???, itreturnsTherightOperand.2.unlikethelogicalor (||) ???,?

PHP? ?? ?? ??? ?? ?? ?? ?? endif ? endfor? ?? ?? ? ???? ???? ?? HTML? ???? ???? ? ????. 1. if-elseif-else? ???? ???? endif? ??? ?? ??? ? ?????. 2. Foreach? ??? ???? ????? ? ?? Endforeach? ??? ?? ???? ?????. 3. ?? ???? ?? ??, ??? ?? ?????. ? ????? ???? ??? ??? ????. ?? ?? ??, ??? ?? ? HTML ?? ??? ?????. ??? ??? ??? ?? Curly Braces? ??? PHP ??? ?? ????????. ??? PHP? HTML? ???? ?? ?? ?? ???? ????? ????? ?? ??? ?????.

AlwaysUseStricTequality (=== ?! ==) injavaScriptToaVoidUnexpectedBehaviorfromTypecoercion.1.looseequality (==) canLeadTocounterIntuitVeresultSbecAuseItPerformStypeConversion, Making0 == false, ""== ??, "== 1, undeLalltue.2

useGuardClaUsestorEturnearlylylyly ? flattenstructure.2. ExtractComplexConditionScriptiveFunctionSorvariblesforClarityandReus.3

??? ??, ???? ??? ? ?? ??? ?? ??? ??? ????. 1. ??? ???? ???? ??? ?? ???? O (n)?? ?? ????? ??? ?? ???????. 2. ??? ???? ????? ?? O (1) ??? ?? ?? ? ?? ?? ?? ? ?? ??? ??? ? ?? O (1)? ?? ???? ??? ? ? ????. 3. ?? ??? ?? ?? ??? ???? ?? ??? ???? ? ????. 4. ?? ??, ??? ??, ? integer ?? ?? ? ?? ??? ??? ?, ? ????? ??? ????? ??; 5. ?? ?? (? : C/C, Java, JavaScript, C#)? ???? ??? ??? ???? ?? ???? ?? ????????. SWI? ?? ???????

?? && toskipexpensiveoperationsandguardagainstnull/undefinedby-short-circitingonfalsyvalues; 2.use || tosetdefaultseffiled, butbewareittreatsallfalsyvalues (like0) asinvalid, soprefer ?? fornull/undefinedonly;
