W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 函数</h1> <p>在这个例子中,myFunction 是一个函数构造函数:</p> <p id="demo"></p> <script> function myFunction(arg1, arg2) { this.firstName = arg1; this.lastName = arg2; } var x = new myFunction("Bill","Gates") document.getElementById("demo").innerHTML = x.firstName; </script> </body> </html>