For-in and statements are typical iterative statements used to enumerate the attributes of objects! The basic syntax format of the for-in statement is as follows: for (variableinobject) & amp; nbsp; statement
For-in and statements are typical iterative statements used to enumerate the attributes of objects!
The basic syntax format of the for-in statement is as follows:
For (variable in object) statement
Take a look at the js Code as follows:
Script for (var a in navigator) {document. write (a +"
");} Script
The above js Code runs as follows:
AppCodeNameappMinorVersionbrowserLanguagecookieEnabledcpuClassmimeTypespluginssystemLanguageuserLanguagemsDoNotTrackgeolocation appNameappVersionplatformuserAgentonLinejavaEnabledtaintEnabled
In this example, the for-in statement is used to display all the attributes of the navigator object, which is similar to the for statement. Note that:
The attribute names output by the for-in statement are unordered. The order varies with the browser!
I have also written an article about the usage of the for-in statement before: Use of the for... in statement in js