diff --git a/1-js/03-code-quality/04-ninja-code/article.md b/1-js/03-code-quality/04-ninja-code/article.md index 4ed183fa..bc1283aa 100644 --- a/1-js/03-code-quality/04-ninja-code/article.md +++ b/1-js/03-code-quality/04-ninja-code/article.md @@ -45,7 +45,7 @@ The Dao hides in wordlessness. Only the Dao is well begun and well completed. ``` -Another way to code faster (and much worse!) is to use single-letter variable names everywhere. Like `a`, `b` or `c`. +Another way to code faster is to use single-letter variable names everywhere. Like `a`, `b` or `c`. A short variable disappears in the code like a real ninja in the forest. No one will be able to find it using "search" of the editor. And even if someone does, he won't be able to "decipher" what the name `a` or `b` means. @@ -83,17 +83,19 @@ While choosing a name try to use the most abstract word. Like `obj`, `data`, `va - **Name a variable by its type: `str`, `num`...** - Give them a try. A young ninja may wonder -- do such names make the code worse? Actually, yes! + Give them a try. A young initiate may wonder -- are such names really useful for a ninja? Indeed, they are! - Sure, the variable name still means something. It says what's inside the variable: a string, a number or something else. But when an outsider tries to understand the code, he'll be surprised to see that there's actually no information at all! + Sure, the variable name still means something. It says what's inside the variable: a string, a number or something else. But when an outsider tries to understand the code, he'll be surprised to see that there's actually no information at all! And will ultimately fail to alter your well-thought code. - Indeed, the value type is easy to find out by debugging. But what's the meaning of the variable? Which string/number does it store? There's just no way to figure out without a good meditation! + The value type is easy to find out by debugging. But what's the meaning of the variable? Which string/number does it store? + + There's just no way to figure out without a good meditation! - **...But what if there are no more such names?** Just add a number: `data1, item2, elem5`... ## Attention test -Only a truly attentive programmer should be able to understand the code. But how to check that? +Only a truly attentive programmer should be able to understand your code. But how to check that? **One of the ways -- use similar variable names, like `date` and `data`.** diff --git a/1-js/04-object-basics/01-object/article.md b/1-js/04-object-basics/01-object/article.md index 31e164d9..91095489 100644 --- a/1-js/04-object-basics/01-object/article.md +++ b/1-js/04-object-basics/01-object/article.md @@ -228,7 +228,7 @@ That can become a source of bugs and even vulnerabilies if we intent to store ar In that case the visitor may choose "__proto__" as the key, and the assignment logic will be ruined (as shown above). -There exist a way to make objects treat `__proto__` as a regular property, we'll cover it later, but first we need to know more about objects to understand it. +There exist a way to make objects treat `__proto__` as a regular property, we'll cover it later, but first we need to know more about objects to understand it. There's another data structure [Map](info:map-set-weakmap-weakset), that we'll learn in the chapter , which supports arbitrary keys. Also ```` @@ -411,8 +411,8 @@ So, "49" is an integer property name, because when it's transformed to an intege ```js run // Math.trunc is a built-in function that removes the decimal part alert( String(Math.trunc(Number("49"))) ); // "49", same, integer property -alert( String(Math.trunc(Number("+49"))) ); // "49", not same ⇒ not integer property -alert( String(Math.trunc(Number("1.2"))) ); // "1", not same ⇒ not integer property +alert( String(Math.trunc(Number("+49"))) ); // "49", not same "+49" ⇒ not integer property +alert( String(Math.trunc(Number("1.2"))) ); // "1", not same "1.2" ⇒ not integer property ``` ````