@@ -338,79 +338,79 @@ class Square {
338338
339339๋ ์์ธํ ์๊ณ ์ถ๋ค๋ฉด, [ ์ฝ๋๋ฅผ ์คํํ๋ Pull Request๋ฅผ ๋ณด์ธ์] ( https://github.com/microsoft/TypeScript/pull/379200 ) .
340340
341- ## Short-Circuiting Assignment Operators
341+ ## ๋จ์ถ ํ ๋น ์ฐ์ฐ์ ( Short-Circuiting Assignment Operators)
342342
343- JavaScript, and a lot of other languages, support a set of operators called _ compound assignment _ operators .
344- Compound assignment operators apply an operator to two arguments, and then assign the result to the left side .
345- You may have seen these before :
343+ JavaScript์ ๋ง์ ์ธ์ด๋ _ ๋ณตํฉ ํ ๋น (compound assignment) _ ์ฐ์ฐ์๋ผ๊ณ ๋ถ๋ฆฌ๋ ์ฐ์ฐ์ ์งํฉ์ ์ง์ํฉ๋๋ค .
344+ ๋ณตํฉ ํ ๋น ์ฐ์ฐ์๋ ๋ ๊ฐ์ ์ธ์์ ์ฐ์ฐ์๋ฅผ ์ ์ฉํ ๋ค์ ๊ฒฐ๊ณผ๋ฅผ ์ผ์ชฝ์ ํ ๋นํฉ๋๋ค .
345+ ์ด์ ์ ์๋์ ๊ฐ์ ๊ฒ์ ๋ณธ ์ ์ด ์์ ๊ฒ์
๋๋ค :
346346
347347``` ts
348- // Addition
348+ // ๋ง์
349349// a = a + b
350350a += b ;
351351
352- // Subtraction
352+ // ๋บ์
353353// a = a - b
354354a -= b ;
355355
356- // Multiplication
356+ // ๊ณฑ์
357357// a = a * b
358358a *= b ;
359359
360- // Division
360+ // ๋๋์
361361// a = a / b
362362a /= b ;
363363
364- // Exponentiation
364+ // ์ง์ํ
365365// a = a ** b
366366a * *= b ;
367367
368- // Left Bit Shift
368+ // ์ผ์ชฝ ๋นํธ ์ํํธ
369369// a = a << b
370370a <<= b ;
371371```
372372
373- So many operators in JavaScript have a corresponding assignment operator !
374- Up until recently, however, there were three notable exceptions: logical _ and_ (` && ` ), logical _ or_ (` || ` ), and nullish coalescing (` ?? ` ).
373+ JavaScript์ ๋ง์ ์ฐ์ฐ์์ ์์ ๊ฐ์ ํ ๋น ์ฐ์ฐ์๊ฐ ์์ต๋๋ค !
374+ ๊ทธ๋ฌ๋ ์ต๊ทผ๊น์ง๋ ๋
ผ๋ฆฌ _ and_ ์ฐ์ฐ์ (` && ` ), ๋
ผ๋ฆฌ _ or_ ์ฐ์ฐ์ (` || ` ) ๋ฐ null๊ณผ ๊ฐ์ ๊ฒ์ ๋ณํฉํ๋ ์ฐ์ฐ์ ( nullish coalescing) (` ?? ` )์ ์ธ ๊ฐ์ง ์ฃผ๋ชฉํ ๋งํ ์์ธ๊ฐ ์์์ต๋๋ค .
375375
376- That's why TypeScript 4.0 supports a new ECMAScript feature to add three new assignment operators: ` &&= ` , ` ||= ` , and ` ??= ` .
376+ ์ด๊ฒ์ด TypeScript 4.0์ด ์๋ก์ด ํ ๋น ์ฐ์ฐ์ ` &&= ` ,` ||= ` ๋ฐ ` ??= ` ๋ฅผ ์ถ๊ฐํ๋ ์๋ก์ด ECMAScript ๊ธฐ๋ฅ์ ์ง์ํ๋ ์ด์ ์
๋๋ค .
377377
378- These operators are great for substituting any example where a user might write code like the following:
378+ ์ด๋ฌํ ์ฐ์ฐ์๋ ์ฌ์ฉ์๊ฐ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ฅผ ์์ฑํ ์ ์๋ ๋ชจ๋ ์๋ฅผ ๋์ฒดํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
379379
380380``` ts
381381a = a && b ;
382382a = a || b ;
383383a = a ?? b ;
384384```
385385
386- Or a similar ` if ` block like
386+ ํน์ ์๋์ ๋น์ทํ ` if ` ๋ธ๋ก
387387
388388``` ts
389- // could be 'a ||= b'
389+ // 'a ||= b'๋ก ๋์ฒด ๊ฐ๋ฅ
390390if (! a ) {
391391 a = b ;
392392}
393393```
394394
395- There are even some patterns we've seen (or, uh, written ourselves) to lazily initialize values, only if they'll be needed .
395+ ์ฐ๋ฆฌ๊ฐ ๋ณธ(ํน์ ์ง์ ์์ฑํ) ์ฝ๋ ํจํด ์ค ํ์ํ ๊ฒฝ์ฐ์๋ง ๊ฐ์ ์ง์ฐ ์ด๊ธฐํ์ํค๊ธฐ ์ํ ํจํด๋ ์์ต๋๋ค .
396396
397397``` ts
398398let values: string [];
399399(values ?? (values = [])).push (" hello" );
400400
401- // After
401+ // ์ดํ
402402(values ?? = []).push (" hello" );
403403```
404404
405- (look, we're not proud of _ all _ the code we write ...)
405+ (๋ณด์ธ์, ์ฐ๋ฆฌ๊ฐ ์์ฑํ _ ๋ชจ๋ _ ์ฝ๋๊ฐ ์๋์ค๋ฌ์ด ๊ฒ์ ์๋๋๋ค ...)
406406
407- On the rare case that you use getters or setters with side-effects, it's worth noting that these operators only perform assignments if necessary .
408- In that sense, not only is the right side of the operator " short-circuited" - the assignment itself is too .
407+ ๋๋ฌผ์ง๋ง ๋ถ์ ํจ๊ณผ(side-effects)๊ฐ ์๋ getter ๋๋ setter๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ด๋ฌํ ์ฐ์ฐ์๊ฐ ํ์ํ ๊ฒฝ์ฐ์๋ง ํ ๋น์ ์ํํ๋ค๋ ์ ์ ์ ์ํ ํ์๊ฐ ์์ต๋๋ค .
408+ ๊ทธ๋ฐ ์๋ฏธ์์ ์ฐ์ฐ์์ ์ค๋ฅธ์ชฝ์ด "๋จ์ถ ( short-circuited)"๋ ๋ฟ๋ง ์๋๋ผ ํ ๋น ์์ฒด๋ ๋ง์ฐฌ๊ฐ์ง์
๋๋ค .
409409
410410``` ts
411411obj .prop || = foo ();
412412
413- // roughly equivalent to either of the following
413+ // ๋ค์ ์ค ํ๋์ ๋๋ต ๋์ผํจ
414414
415415obj .prop || (obj .prop = foo ());
416416
@@ -419,14 +419,14 @@ if (!obj.prop) {
419419}
420420```
421421
422- [ Try running the following example ] ( https://www.typescriptlang.org/play?ts=Nightly#code/MYewdgzgLgBCBGArGBeGBvAsAKBnmA5gKawAOATiKQBQCUGO+TMokIANkQHTsgHUAiYlChFyMABYBDCDHIBXMANoBuHI2Z4A9FpgAlIqXZTgRGAFsiAQg2byJeeTAwAslKgSu5KWAAmIczoYAB4YAAYuAFY1XHwAXwAaWxgIEhgKKmoAfQA3KXYALhh4EA4iH3osWM1WCDKePkFUkTFJGTlFZRimOJw4mJwAM0VgKABLcBhB0qCqplr63n4BcjGCCVgIMd8zIjz2eXciXy7k+yhHZygFIhje7BwFzgblgBUJMdlwM3yAdykAJ6yBSQGAeMzNUTkU7YBCILgZUioOBIBGUJEAHwxUxmqnU2Ce3CWgnenzgYDMACo6pZxpYIJSOqDwSkSFCYXC0VQYFi0NMQHQVEA ) to see how that differs from _ always _ performing the assignment .
422+ [ ๋ค์ ์์๋ฅผ ์คํํด๋ณด์ธ์ ] ( https://www.typescriptlang.org/play?ts=Nightly#code/MYewdgzgLgBCBGArGBeGBvAsAKBnmA5gKawAOATiKQBQCUGO+TMokIANkQHTsgHUAiYlChFyMABYBDCDHIBXMANoBuHI2Z4A9FpgAlIqXZTgRGAFsiAQg2byJeeTAwAslKgSu5KWAAmIczoYAB4YAAYuAFY1XHwAXwAaWxgIEhgKKmoAfQA3KXYALhh4EA4iH3osWM1WCDKePkFUkTFJGTlFZRimOJw4mJwAM0VgKABLcBhB0qCqplr63n4BcjGCCVgIMd8zIjz2eXciXy7k+yhHZygFIhje7BwFzgblgBUJMdlwM3yAdykAJ6yBSQGAeMzNUTkU7YBCILgZUioOBIBGUJEAHwxUxmqnU2Ce3CWgnenzgYDMACo6pZxpYIJSOqDwSkSFCYXC0VQYFi0NMQHQVEA ) ์์๋ฅผ ํตํด _ ํญ์ _ ํ ๋น์ ์ํํ๋ ๊ฒ๊ณผ ์ด๋ป๊ฒ ๋ค๋ฅธ์ง ํ์ธํด๋ณด์ธ์ .
423423
424424``` ts
425425const obj = {
426426 get prop() {
427427 console .log (" getter has run" );
428428
429- // Replace me !
429+ // ์ด๊ณณ์ ๋ฐ๊ฟ๋ณด์ธ์ !
430430 return Math .random () < 0.5 ;
431431 },
432432 set prop(_val : boolean ) {
@@ -446,10 +446,10 @@ console.log("This one *sometimes* runs the setter");
446446obj .prop || = foo ();
447447```
448448
449- We'd like to extend a big thanks to community member [ Wenlu Wang] ( https://github.com/Kingwl ) for this contribution!
449+ ๊ธฐ์ฌํด์ฃผ์ ์ปค๋ฎค๋ํฐ ๋ฉค๋ฒ [ Wenlu Wang] ( https://github.com/Kingwl ) ๋์๊ฒ ํฐ ๊ฐ์ฌ๋ฅผ ํํฉ๋๋ค.
450450
451- For more details, you can [ take a look at the pull request here ] ( https://github.com/microsoft/TypeScript/pull/37727 ) .
452- You can also [ check out TC39's proposal repository for this feature ] ( https://github.com/tc39/proposal-logical-assignment/ ) .
451+ ๋ ์์ธํ ๋ด์ฉ์ ๋ณด๊ณ ์ถ์ผ์๋ค๋ฉด [ ์ด ํ ๋ฆฌํ์คํธ๋ฅผ ํ์ธํด๋ณด์ธ์ ] ( https://github.com/microsoft/TypeScript/pull/37727 ) .
452+ [ TC39 ์ ์ ์ ์ฅ์์์๋ ์ด ๊ธฐ๋ฅ์ ํ์ธํ ์ ์์ต๋๋ค. ] ( https://github.com/tc39/proposal-logical-assignment/ ) .
453453
454454## ` unknown ` on ` catch ` Clause Bindings
455455
0 commit comments