Monday, 8 January 2018

Java Script Array of object


Java script support object data type which can be used to store data as in structure ( C Language). Object of array, you can use for pass bulk of record to server in ajax mvc application. Object of array minimize your work and enable you to process records instead of individual variable. Following code demonstrate to handle array of object with input and print operation.

<html>
<head>
    <title>Girfa Java Script Array of object</title>
</head>
<body>
    <h2>

        <script>
            var ob = [];
            ob.push({ roll: "101", name: "sona", city: "vns" });
            ob.push({ roll: "102", name: "mona", city: "alld" });
            ob.push({ roll: "103", name: "sita", city: "lku" });
            ob.push({ roll: "104", name: "gita", city: "dlh" });
            ob.forEach(function (entry) {
                document.write(entry.roll + " " + entry.name + " " + entry.city +"<br>");
            });
        </script>
    </h2>
</body>

No comments:

Post a Comment