Best Jquery ,javascript, HTML5 CSS3 tutorial with jquery examples, php script , demos for beginners, web designers and web developers.

Jquery

Jquery Training

Jquery training blog

How a Loop through a JavaScript object?

How a Loop through a JavaScript object? Javascript Objects are Variables Containing Variables. In JavaScript, an object is an entity, with property and type In JavaScript objects the name:values pair are termed as properties. var student = {studentName:”Jquery Training”, addrees:”Web”, age:02, type:”blog”}; <!DOCTYPE html> <html> <head> <script src=”https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js”></script> </head> <body> How a Loop through a Continue Reading


How a Loop through a JavaScript object?
Javascript Objects are Variables Containing Variables.
In JavaScript, an object is an entity, with property and type
In JavaScript objects the name:values pair are termed as properties.

var student = {studentName:”Jquery Training”, addrees:”Web”, age:02, type:”blog”};

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>

</head>
<body>
How a Loop through a JavaScript object?

<div id="preview">
</div>

<script>
var students = {
"one": "50 students",
"two": "30 students",
"three":"70 students"
};

for (var key in students) {
if (students.hasOwnProperty(key)) {
$('#preview').append('Class '+key + " : " + students[key]+"<br/>");
}
}
</script>
</body>
</html>

Storing Objects in HTML5 localStorage

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>

</head>
<body>

Storing Objects in HTML5 localStorage

<div id="preview-obj">
</div>

<script>
var testObject = { 'one': 1, 'two': 2, 'three': 3 };

var students = {
"one": "50 students",
"two": "30 students",
"three":"70 students"
};

localStorage.setItem('students', JSON.stringify(students));

var retrievedObject = localStorage.getItem('students');
var obj=JSON.parse(retrievedObject);

for (var key in obj) {
if (obj.hasOwnProperty(key)) {
$('#preview-obj').append('Class '+key + " : " + obj[key]+"<br/>");
}
}

</script>

</body>
</html>






About the author

Joydeb Choudhury holds a Master's degree in Computer Application from I.G.N.O.U. After working as a web developer in various companies he has started bloging in 2016.

Recent Posts of blog

Downalod Free Php Scripts