如何打印 JavaScript 对象的内容?
javascriptweb developmentfront end technology
要打印 JavaScript 对象的内容,您可以尝试运行以下代码。这里,使用 new 关键字创建对象 −
示例
<!DOCTYPE html> <html> <body> <p id="test"></p> <script> var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology ="C++"; document.getElementById("test").innerHTML = dept.employee + " is working on " + dept.technology + " technology."; </script> </body> </html>