{"id":1231,"date":"2023-05-21T07:08:18","date_gmt":"2023-05-21T07:08:18","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=1231"},"modified":"2023-05-21T07:08:19","modified_gmt":"2023-05-21T07:08:19","slug":"what-is-loop-though-the-properties-of-an-object","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/what-is-loop-though-the-properties-of-an-object\/","title":{"rendered":"What is Loop Though the Properties of an Object?"},"content":{"rendered":"\n<p>The for\/in a loop is usually used to loop through the properties of an object. You can give any name for the variable, but the object\u2019s name should be the same as an already existing object you need to loop through.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for (variablename in objectname)\n\n{\n\nlines of code to be executed\n\n}\n<\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;\n&lt;head&gt;\n    &lt;script type=\"text\/javascript\"&gt;\n        var employee={first:\"John\", last:\"Doe\", department:\"Accounts\"};\n\t\tvar\t\tdetails = \"\";\n\t\tdocument.write(\"&lt;b&gt;Using for\/in loops &lt;\/b&gt;&lt;br \/&gt;\");\n        for (var x in employee)\n        {\n\t\tdetails = x + \": \" + employee[x];\n\t\tdocument.write(details + \"&lt;br \/&gt;\");\n        }\n    &lt;\/script&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The for\/in a loop is usually used to loop through the properties of an object&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1231"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=1231"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1231\/revisions"}],"predecessor-version":[{"id":1232,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1231\/revisions\/1232"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=1231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=1231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=1231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}