In The first and most common way of writing: nums = [1,2,3,4] for (let i=0; i<nums.length; i++){ console.log(nums[i]) } Second type: The second for (let item of nums){ console.log(item) } The third type: The third writing method let p = {name:"zhang", age:10} for(let key in p){ console.log(p[key]) } Output:
for (let index in nums){ console.log(nums[index]) }
When defining variables This is the end of this article about the detailed introduction of for/of, for/in in JavaScript. For more relevant JavaScript for/of, for/in introduction content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed tutorial on installation and configuration of compressed version of MySQL database
>>: CSS realizes the mask effect when the mouse moves to the image
In this section, the author describes the special...
Effect The pictures in the code can be changed by...
mapGetters Helper Function mapGetters helper func...
Enable remote access to MySQL By default, MySQL u...
In the case of complete separation of the front-e...
Table of contents 1. Create a sql script file con...
Anti-shake: Prevent repeated clicks from triggeri...
When exporting data to operations, it is inevitab...
binlog is a binary log file, which records all my...
Table of contents 1. Get a random Boolean value (...
Recently, I need to use a lot of fragmented pictu...
Mine is: <!DOCTYPE html> Blog Garden: <!...
Test project: react-demo Clone your react-demo pr...
For Linux system administrators, it is crucial to...
Table of contents 1. Closure 2. Closure usage sce...