From 09fe426b5949b2d3c2417f78a34f69891c495708 Mon Sep 17 00:00:00 2001 From: many2many <6168830@qq.com> Date: Tue, 24 Sep 2024 14:35:10 +0800 Subject: [PATCH] changed --- docs/chapter02.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/chapter02.md b/docs/chapter02.md index 110f41f..3458202 100644 --- a/docs/chapter02.md +++ b/docs/chapter02.md @@ -317,26 +317,26 @@ ES6允许使用 “箭头”( => )定义函数。 示例: ```javascript - let v = v => v + let v = v => v; // 等同于 let f = function(f){ - return f - } + return f; + }; ``` 如果箭头函数 不需要参数 或 需要多个参数 ,就在剪头前使用()括起来参数部分。 ```javascript -let f = () => 5 +let f = () => 5; // 等同于 -let f = function() { return 5 } +let f = function() { return 5 }; -let sum = (num1, num2) => num1 + num2 +let sum = (num1, num2) => num1 + num2; // 等同于 let sum = function(num1, num2){ - return num1 + num2 -} + return num1 + num2; +}; ``` 箭头函数的一个用处是简化回调函数。