func(thing) 与 func(null) 分别打印什么?
What will this code output to the log?
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: hard
分类: JavaScript Functions
标签: default parameters, undefined, null
参考答案摘要
默认参数只在实参为 undefined 时生效。 thing 未赋值是 undefined ,因此打印 no arg ;传入 null 会覆盖默认值,打印 null 。
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。