104 lines
2.3 KiB
HTML
104 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Document</title>
|
||
</head>
|
||
<body>
|
||
|
||
|
||
<script>
|
||
|
||
//函数
|
||
//00-函数
|
||
//No.1
|
||
// function 函数名(){
|
||
// //function code
|
||
// }
|
||
|
||
//No.2
|
||
// let 函数名 = function (){
|
||
// //function code
|
||
// }
|
||
|
||
|
||
//No.3
|
||
// let 函数名 =()=>{
|
||
// //function code
|
||
// }
|
||
|
||
|
||
//01-匿名函数
|
||
//1.不会独立存在
|
||
//2.只要是函数去掉函数名就是匿名函数
|
||
|
||
|
||
//函数传参
|
||
// function func0(形参){
|
||
// //实参以形参的形式使用
|
||
// console.log("func0,start");
|
||
|
||
// console.log(`参数:${形参}`);
|
||
// }
|
||
// //调用函数,并传参(实参)
|
||
// func0('tututu');
|
||
// func0("突突突啥子");
|
||
|
||
|
||
//多参数
|
||
//形参和实参(一一对应)
|
||
// function func0(形参0, 形参1){
|
||
// //实参以形参的形式使用
|
||
// console.log("func0,start");
|
||
|
||
// console.log(`参数:${形参0 + 形参1}`);
|
||
// }
|
||
// //调用函数,并传参(实参)
|
||
// func0('tututu',`?`);
|
||
// func0("突突突啥子","不知道");
|
||
|
||
|
||
//正常传参
|
||
//1.有几个形参 不一定要传几个实参
|
||
//2.传输不能跳着传,必需一个一个排队传
|
||
|
||
|
||
|
||
//强上
|
||
//目的:
|
||
//我就要跳着传,我就不排队
|
||
// function func2(参数对象){
|
||
// let 默认参数 = {形参0:"请设置参数0",形参1:"请设置参数1"};
|
||
// let {形参0,形参1}= Object.assign({默认参数,参数对象});
|
||
|
||
|
||
// console.log("func0,start");
|
||
// console.log(`参数:${形参0 + 形参1}`);
|
||
|
||
// }
|
||
// func2({
|
||
// // 形参0:"突突突",
|
||
// 形参1:'兔子'
|
||
// })
|
||
|
||
|
||
//箭头函数
|
||
//()=>{}
|
||
//No.1
|
||
let f0 =参数0=>{};
|
||
|
||
//NO.2
|
||
//let f1 = 参数0=> a=2;
|
||
|
||
let f2 = 参数0 =>{
|
||
return a=2;
|
||
};
|
||
//f1与f2一样的
|
||
|
||
|
||
</script>
|
||
|
||
|
||
</body>
|
||
</html> |