-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#138 5 Tips to Write Better Conditionals in JavaScript #139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要注意调整语序,英文和中文习惯不同
@@ -0,0 +1,467 @@ | |||
## 5 Tips to Write Better Conditionals in JavaScript(用 JavaScript 写出更好条件语句的 5 个技巧) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
题目我觉得可以改改,优化javascript条件语句的5个技巧
|
||
At first glance, the above example looks good. However, what if we get more red fruits, say cherry and cranberries? Are we going to extend the statement with more || ? | ||
|
||
乍一看,上面的例子看起来不错。然而,如果我们得到更多的红色水果,比如樱桃和小红莓呢?我们要用更多的 || 来扩展这个表述吗? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果我们得到更多水果,这里不看原文就有点突兀,因为get翻译为得到不妥
如果还有更多类型的水果需要判断呢
|
||
Look at the example above, we want to print the fruit name if it's available or we will print unknown. We can avoid the conditional fruit && fruit.name checking with default function parameter & destructing. | ||
|
||
看看上面的例子,我们想打印水果名,如果它是可用的,或者我们将打印 unknown。我们可以避免使用与默认函数参数和解构对条件 fruit && fruit.name 进行检查。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果它是可用的,这里需要调整语序
|
||
Much cleaner now right? In a similar way, if we want to test if any of the fruit is red, we can use `Array.some` to achieve it in one line. | ||
|
||
现在干净多了,对吧?类似地,如果我们想测试任何一个水果是红色的,我们可以使用 `Array.some` 来实现它在一行。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用一行语句实现它
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
根据建议,已经对pr做出了相应的修改。额外修改了一处用词欠准确的部分。
translation/#138-5-Tips-to-Write-Better-Conditionals-in-JavaScript.md
Outdated
Show resolved
Hide resolved
translation/#138-5-Tips-to-Write-Better-Conditionals-in-JavaScript.md
Outdated
Show resolved
Hide resolved
translation/#138-5-Tips-to-Write-Better-Conditionals-in-JavaScript.md
Outdated
Show resolved
Hide resolved
translation/#138-5-Tips-to-Write-Better-Conditionals-in-JavaScript.md
Outdated
Show resolved
Hide resolved
translation/#138-5-Tips-to-Write-Better-Conditionals-in-JavaScript.md
Outdated
Show resolved
Hide resolved
认领校对 |
(提交翻译请使用下面的模板,其他类型pr请删除)
closes #138
1.译者信息
(请大家一定要填伯乐在线个人主页这一项,方便署名,🙏)
2.疑问区
无
3.自查表
4.发布信息(译者无需填写)
发布链接:http://blog.jobbole.com/114671/
@hanxiaomax