Object tutorial Two in JavaScript

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Objects tutorial JavaScript</title>
    <script>
        var person = new Object();

        person.firstName = "Ram";
        person.lastName = "kumar";
        person.age = 25;

        document.write(person + "<br><br>");
        document.write(person.firstName + "<br><br>");
        document.write(person.lastName + "<br><br>");
        document.write(person.age + "<br><br>");
        // Another way to print Object value as shown below:
        document.write(person["firstName"] + "<br><br>");
        document.write(person["lastName"] + "<br><br>");
        document.write(person["age"] + "<br><br>");
        console.log(person);
        console.log(person.firstName);
        console.log(person.lastName);
        console.log(person.age);
    </script>
</head>

<body>
</body>

</html>



Comments

Popular posts from this blog

Generators tutorial in Advance JavaScript

Document Object Module DOM querySelector and querySelectorAll tutorial in JavaScript

Find Even and Odd Numbers with Loops tutorial in JavaScript