如何使用 JavaScript 创建一个自定义对象?
如要使用 JavaScript 创建一个自定义对象,请尝试以下代码
示例
<!DOCTYPE html> <html> <body> <p id="test"></p> <script> var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology ="Java"; document.getElementById("test").innerHTML = dept.employee + " is working on " + dept.technology + " technology."; </script> </body> </html>
广告