查找 Arrow 函数错误
找错误 简单
题目
这个 arrow 函数有 语法错误. 什么是 错误?
代码
const add = (a, b) {
return a + b;
};
console.log(add(2, 3));
提示
Arrow 函数需要 arrow 之间参数 and 请求体.
解释
Arrow function syntax requires => between the parameter list and the body. The parameter list (a, b) is present, but the => is missing. The corrected code is: const add = (a, b) => { return a + b; };
相关资源
相关课程
- JavaScript 函数
学习关于函数 declarations and arrow 函数.
相关速查表
- JavaScript Cheatsheet
快速引用 for JavaScript 函数语法.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。