Skip to content

Update translation of 1-js/02-first-steps/15-function-expressions#535

Merged
bemself merged 4 commits intomasterfrom
leviding-patch-1
Nov 28, 2019
Merged

Update translation of 1-js/02-first-steps/15-function-expressions#535
bemself merged 4 commits intomasterfrom
leviding-patch-1

Conversation

@leviding
Copy link
Copy Markdown
Member

@leviding leviding commented Nov 26, 2019

目标章节:1-js/02-first-steps/15-function-expressions

当前上游最新 commit:f073dbd

所做更改如下:

  1. 更新译文
  2. 将函数表达式和箭头函数拆分成两章
文件名 参考上游 commit 更改(理由)
article.md 6165a9a 更新译文

@leviding leviding changed the title WIP Update translation of 1-js/02-first-steps/15-function-expressions Update translation of 1-js/02-first-steps/15-function-expressions Nov 27, 2019
Copy link
Copy Markdown
Collaborator

@bemself bemself left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢翻译,校对完成,欢迎讨论~

```

下面是另一种创建函数的方法叫**函数表达式**。
这里展示了被称为 **函数表达式** 的创建函数的另一种语法
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[这里展示了被称为 函数表达式 的创建函数的另一种语法。]
->
[另一种创建函数的语法称为函数表达式。]

原文:There is another syntax for creating a function that is called a Function Expression.

```

在这里,函数被创建并像其他赋值一样,明确的分配给了一个变量。不管函数如何定义,它只是一个存储在变量中的值 `sayHi`。
在这里,函数被创建并像其他赋值一样,被明确地分配给了一个变量。不管函数是被怎样定义的,都只是一个存储在变量中的值 `sayHi`。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[都只是一个存储在变量中的值 sayHi。] -> [都只是一个存储在变量 sayHi 中的值。]
原文:it's just a value stored in the variable sayHi.

## 回调函数

让我们来看更多例子,使用函数表达式以值的方式传递函数
让我们来看更多关于以值的方式传递函数和函数表达式的使用的例子
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[让我们来看更多关于以值的方式传递函数和函数表达式的使用的例子。]
->
[让我们多举几个例子,看看如何将函数作为值来传递以及使用函数表达式。]

仅供参考~

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

让我们多举几个例子,看看如何将函数作为值来传递以及如何使用函数表达式。

不错

```

实际开发中,类似的函数是很常见的。现实生活中的实现与上述示例之间的主要区别在于,现实生活中的功能使用更复杂的方式与用户进行交互,而不是简单 `confirm`(确认)。在浏览器中,这样的功能通常会绘制一个漂亮的问题窗口。但这是另一回事
在实际开发中,这样的的函数是非常有用的。实际开发与上述示例最大的区别是,实际开发中的函数会通过更加更加复杂的方式与用户进行交互,而不是通过简单的 `confirm`。在浏览器中,这样的函数通常会绘制一个漂亮的提问窗口。但这是另外一件事了
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[更加更加复杂] -> [更加复杂]

在实际开发中,这样的的函数是非常有用的。实际开发与上述示例最大的区别是,实际开发中的函数会通过更加更加复杂的方式与用户进行交互,而不是通过简单的 `confirm`。在浏览器中,这样的函数通常会绘制一个漂亮的提问窗口。但这是另外一件事了

`ask` 参数调用**回调函数**或只是**回调**。
`ask` 的 `showOk` 和 `showCancel` 两个 arguments 对象可以被称为 **回调函数** 或简称 **回调**。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[askshowOkshowCancel 两个 arguments 对象]
->
[ask 的两个参数值 showOkshowCancel]


如果我们只有一个参数,那么括号可以省略,甚至更短:
```smart header="什么时候选择函数声明与函数表达式?"
根据经验,当我们需要声明一个函数时,首先考虑的是函数声明。它能够为组织代码提供更多的灵活性。因为我们可以在声明这些函数之前调用这些函数。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[首先考虑的是函数声明] -> [首先考虑函数声明语法]

这里主要是想加粗 函数声明四字。另外文中其他地方也有类似的可能需要加粗~

原文:As a rule of thumb, when we need to declare a function, the first to consider is Function Declaration syntax.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bemself 原文没加粗,这里也就不加粗了。

@javascript-translate-bot
Copy link
Copy Markdown

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@leviding
Copy link
Copy Markdown
Member Author

@bemself 均已修改,看看还有什么问题?没有问题的话,你就可以 merge 了。

选择下图中的 Squash and merge.

image

@bemself bemself merged commit 0057b1a into master Nov 28, 2019
@bemself bemself deleted the leviding-patch-1 branch November 28, 2019 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants