js uses for in loop to obtain all attributes and instances of values of an object
Examples are as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/"> <html xmlns="http:///1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled document</title> <script> function fun1(obj){ var names=""; /*for in can be used in arrays or objects*/ for(var name in obj){ names+=name+": "+obj[name]+", <br/>"; } (names); } fun1(window); </script> </head> <body> </body> </html>
The above article js uses for in loop to obtain all the attributes and values of an object. This is all the content I share with you. I hope you can give you a reference and I hope you can support me more.
Related Articles
About the method of href and src of img to get variables and assign values
This article mainly introduces the method of href and src of img variables and assignment. Friends who need it can refer to it2014-04-04Example analysis of several situations caused by JS memory leak
This article mainly introduces several situations caused by JS. It analyzes the principle of memory leaks and several common situations caused by JS. If you need it, please refer to it.2020-03-03Detailed explanation of several usages of JS to generate random numbers
Below, the editor will introduce you to a detailed explanation of the usage of JS to generate random numbers. The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2016-06-06New understanding of Form form reset method
The reset method of the Form form in HTML is used to clear the content entered by the user. I used to mistakenly think that it is simply clearing the values in input and other input items.2014-03-03Tutorial for configuring webpack-dev-server using webpack3.0
This article mainly introduces the tutorial of configuring webpack-dev-server using webpack3.0. The editor thinks it is quite good. I will share it with you now and give you a reference. Let's take a look with the editor2018-05-05Analysis of the usage of JavaScript Functional Programming Composition Functions
This article mainly introduces the usage of Composition of JavaScript Functional Programming, and analyzes the concept, principles, usage and operation precautions of combined functions in JavaScript Functional Programming in combination with examples. Friends who need it can refer to it.2019-05-05JS code to add web desktop shortcuts in detail
How to add desktop shortcuts? Many netizens have this question; JS click to add the code to the desktop shortcut for web pages. Friends who need it can refer to it2012-12-12js+FSO traverses the file in the folder and displays it
js+FSO traverses the file in the folder and displays...2007-03-03JavaScript implements all-select and all-select operations
This article mainly introduces JavaScript to you in detail the implementation of all selection and non-select operations. The sample code in the article is introduced in detail and has certain reference value. Interested friends can refer to it.2021-09-09js simulation brush effect
Very good effect, template brush, relatively few codes2008-10-10