扫码关注官方订阅号
欢迎选择我的课程,让我们一起见证您的进步~~
console.log(person1.sayname()); 因为sayname这个函数没有定义返回值,所以person.sayname()的返回值为undefined。
console.log(person1.sayname());
person.sayname()
undefined
console.log(person2.sayname() === person1.sayname()) 因为undefined === undefined
console.log(person2.sayname() === person1.sayname())
undefined === undefined
题主这里主要是没有完全理解函数的返回值。
函数执行完后,都会有一个返回值,这个返回值由
return 表达式
表达式的值即为返回值,默认情况下为undefined
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
console.log(person1.sayname());因为sayname这个函数没有定义返回值,所以person.sayname()的返回值为undefined。console.log(person2.sayname() === person1.sayname())因为undefined === undefined题主这里主要是没有完全理解函数的返回值。
函数执行完后,都会有一个返回值,这个返回值由
表达式的值即为返回值,默认情况下为undefined