From a02f4b2f60c81e09b318a090e5c9c2d2d641c878 Mon Sep 17 00:00:00 2001 From: t7yang Date: Sat, 17 Jul 2021 16:10:02 +0800 Subject: replace wiki links in zh-CN --- files/zh-cn/learn/javascript/building_blocks/return_values/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'files/zh-cn/learn/javascript') diff --git a/files/zh-cn/learn/javascript/building_blocks/return_values/index.html b/files/zh-cn/learn/javascript/building_blocks/return_values/index.html index 38f9fe0eff..dfc53c87e6 100644 --- a/files/zh-cn/learn/javascript/building_blocks/return_values/index.html +++ b/files/zh-cn/learn/javascript/building_blocks/return_values/index.html @@ -39,7 +39,7 @@ console.log(newString); // replaces one substring with another, and returns // a new string with the replacement made -

在第一篇函数文章中,我们确切地看到了这一块代码。我们对 myText 字符串调用 replace() 功能,并通过这两个参数的字符串查找,和子串替换它。当这个函数完成(完成运行)后,它返回一个值,这个值是一个新的字符串,它具有替换的功能。在上面的代码中,我们保存这个返回值,以作为newString变量的内容。

+

在第一篇函数文章中,我们确切地看到了这一块代码。我们对 myText 字符串调用 replace() 功能,并通过这两个参数的字符串查找,和子串替换它。当这个函数完成(完成运行)后,它返回一个值,这个值是一个新的字符串,它具有替换的功能。在上面的代码中,我们保存这个返回值,以作为newString变量的内容。

如果你看看替换功能MDN参考页面,你会看到一个返回值。知道和理解函数返回的值是非常有用的,因此我们尽可能地包含这些信息。

@@ -49,7 +49,7 @@ console.log(newString);

在自定义的函数中使用返回值

-

要从自定义函数返回值,您需要使用…等待它… return 关键字。 我们最近在random-canvas-circles.html示例中看到了这一点。 我们的 draw() 函数绘制100随机圆在HTML的{{htmlelement("canvas")}}:

+

要从自定义函数返回值,您需要使用…等待它… return 关键字。 我们最近在random-canvas-circles.html示例中看到了这一点。 我们的 draw() 函数绘制100随机圆在HTML的{{htmlelement("canvas")}}:

function draw() {
   ctx.clearRect(0,0,WIDTH,HEIGHT);
-- 
cgit v1.2.3-54-g00ecf