7. JAVA Script
7A) Demonstrate the use of object method.
CODE:
<html> <body> <h2>JavaScript Objects</h2> <p id="demo"></p> <script> // Create an object: const person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; // Display some data from the object: document.getElementById("demo").innerHTML = person.firstName + " is " + person.age + " years old."; </script> </body> </html>
OUTPUT:
7B) Demonstrate the use of Java Script array event.
CODE:
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <p id="demo"></p> <script> const fruits = ["Apple", "Orange", "Mango"]; document.getElementById("demo").innerHTML = fruits; </script> </body> </html>
OUTPUT:
7C) Demonstrate the use of link object event.
CODE:
</head> <body> <p>Click the button to create a LINK element.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("LINK"); x.setAttribute("rel", "stylesheet"); x.setAttribute("type", "text/css"); x.setAttribute("href", "styles.css"); document.head.appendChild(x); } </script> </body> </html>
OUTPUT: