123456789101112131415161718192021<!DOCTYPE html>charset="utf-8"W3Cschool教程(w3cschool.cn)该实例中, myFunction 是函数构造函数:id="demo"function myFunction(arg1, arg2) {this.firstName = arg1;this.lastName = arg2;}var x = new myFunction("John","Doe")document.getElementById("demo").innerHTML = x.firstName;