如何在 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>
广告