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
JS running trilogy js running code is divided int...
Preface The apt-get command is a package manageme...
Pure front-end implementation:切片上傳斷點續傳.斷點續傳needs ...
Local Windows remote desktop connects to Alibaba ...
####Management of input and output in the system#...
Table of contents Written in front router.json Ro...
To achieve an effect similar to Windows forms, dr...
1. Install Docker on the server yum install docke...
1. CSS Box Model The box includes: margin, border...
Solution process: Method 1: The default kernel ve...
This article shares the specific code of JavaScri...
Table of contents Concept Introduction Logical ru...
1. 85% of ads go unread <br />Interpretatio...
Today, let's talk about how to use js to achi...
In relational databases, pessimistic locking and ...