<!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>
//函数的参数
// 形参
// 实参
// function abc(a={},b,c){
// console.log(a,b,c)
// console.log(arguments)
// console.log(this)
// }
// var a = () => {
// console.log(this)
// }
// // a()
// // abc(1,2,3,4,5,6,7)
// abc(undefined,100,200)//不想给a传 只想给b传 //{} 100 200
// abc(undefined,100)//不想给a传 只想给b传 // {} 100 undefined
// function getsum(){
// console.log( arguments )
// }
// //函数的参数不确定可以不传入参数
// getsum( 1,2,3,2,33,4 )
// getsum( 1,2,3,2 )
// var a = 100
// var obj1 = {a:1}
// var obj2 = JSON.parse( JSON.stringify(obj1) )
// function fn1(o){
// o.a++
// }
// function fn2(o){
// o++
// console.log( o )
// }
// fn1( obj2 )//传入的是地址
// fn2( a )//传入的是a的值
// console.log(a)
// console.log(obj1,obj2)
//对象的数据存储在堆中 地址存储在栈中
//函数名作为参数传递进去怎么样
function fn1(fn){
console.log(fn)
fn()
}
function fn2(){
console.log(123123)
}
fn1( fn2 )
</script>
</body>
</html>
本文探讨了JavaScript中函数的参数使用方式,包括默认参数、不定数量参数的应用,并通过实例展示了不同参数传递方式的区别。此外,还介绍了如何将一个函数作为另一个函数的参数进行传递。

被折叠的 条评论
为什么被折叠?



