1 Star 0 Fork 84

惨绿青年/前端77

forked from 万少/前端77 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
06-函数参数的默认值.html 1.00 KB
Copy Edit Raw Blame History
万少 authored 2022-05-13 10:52 . 函数形参默认值
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no"
/>
<title>06-函数参数的默认值.html</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
</style>
</head>
<body>
<script>
// (msg="大家好") "大家好" 就是msg 默认值
// 如果 调用函数的时候 你没有传递 就使用默认值
// 如果 传递了参数 就会使用传递的参数 而不会使用 默认值
// const func1 = (msg = '大家好') => {
// console.log(msg);
// };
// func1("你好"); // 输出什么 undefined
// 定义一个函数 接收一个数组 告诉我们 这个数组的长度
const getLength = (arr = []) => console.log(arr.length);
const list=['a'];
getLength(list);
getLength();
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/miserable-green-youth/front-end-77.git
git@gitee.com:miserable-green-youth/front-end-77.git
miserable-green-youth
front-end-77
前端77
js高级第1天

Search