


Detailed explanation of the steps to obtain key and value in js loop map
This time I will bring you a detailed explanation of the steps to obtain key and value with js loop map. What are the precautions for js loop map to obtain key and value? The following is a practical case, let's take a look.
The following method 1 and method 2 have been tested and run by the editor of Script House
Method 1: json format definition
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <script> var dxy={ //Page地址 pageUrl : { menu : "loadPage.htm?url=/collect/menu.page", // 进入菜单页面 guangfaPage : "loadPage.htm?url=/collect/menu.page", // 进入广发信息收集页面 pinganPage : "loadPage.htm?url=/collect/menu.page", // 进入平安信息收集页面 nuonuoPage : "loadPage.htm?url=/collect/menu.page", // 进入诺诺信息收集页面 youbangPage : "loadPage.htm?url=/collect/menu.page", // 进入友邦信息收集页面 inputMobileNo : "loadPage.htm?url=/collect/inputMobileNo.page", // 进入输入手机号页面 readIdCard : "loadPage.htm?url=/collect/readIdCard.page", // 进入读取身份证页面 member : "loadPage.htm?url=/collect/member.page", // 进入输入会员卡号页面 bankCard : "loadPage.htm?url=/collect/bankCard.page", // 进入插入银行卡页面 url : "loadPage.htm?url=/collect/url.page" // 进入跳转url页面 } } for(var key in dxy.pageUrl){ alert(key+" : "+dxy.pageUrl[key]); } </script> </body> </html>
Code 2,
var obj = { "a": 1, "b": 2, "c": 3 }; for (var prop in obj) { if (obj.hasOwnProperty(prop)) { // or if (Object.prototype.hasOwnProperty.call(obj,prop)) for safety... alert("prop: " + prop + " value: " + obj[prop]) } }
The following are the supplements of other netizens. You can refer to them
javascriptLoopTraverse the arrayOutput key value
javascript loops through the array to output key value
Using the $.each method will definitely not work, so use the following method
markers = []; markers[2]=3; markers[3]=7; for(var key in markers){ console.log( key ) console.log( markers[key] ) }
I believe you have mastered the method after reading the case in this article. For more exciting things, please pay attention to php Other related articles on the Chinese website!
Recommended reading:
How to deal with async/await wasted performance problem
jQuery implementation of fuzzy query practical case analysis
The above is the detailed content of Detailed explanation of the steps to obtain key and value in js loop map. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Although the general operations of domestic mobile phones are very similar, there are still some differences in some details. For example, different mobile phone models and manufacturers may have different dual-SIM installation methods. Erzhenwo 12Pro, a new mobile phone, also supports dual-SIM dual standby, but how should dual-SIM be installed on this phone? How to install dual SIM on Realme 12Pro? Remember to turn off your phone before installation. Step 1: Find the SIM card tray: Find the SIM card tray of the phone. Usually, in the Realme 12 Pro, the SIM card tray is located on the side or top of the phone. Step 2: Insert the first SIM card. Use a dedicated SIM card pin or a small object to insert it into the slot in the SIM card tray. Then, carefully insert the first SIM card.

jQuery Tips: How to Quickly Obtain Screen Height In web development, you often encounter situations where you need to obtain the screen height, such as implementing responsive layout, dynamically calculating element size, etc. Using jQuery, you can easily achieve the function of obtaining the screen height. Next, we will introduce some implementation methods of using jQuery to quickly obtain the screen height, and attach specific code examples. Method 1: Use jQuery's height() method to obtain the screen height. By using jQuery's height

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
