搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
JavaScript 教程
JavaScript 函数
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>JavaScript 函数call()方法示例 - 基础教程(div.cn)</title> <body> <h1>JavaScript call() 方法</h1> <script> function Product(name, price) { this.name = name; this.price = price; } function Food(name, price) { Product.call(this, name, price); this.category = "food"; } document.write(new Food("cheese", 12).name); </script> </body> </html>
运行结果