Automatically translated.View original post

Access to array / JavaScript members

# Web Site Writing Basics

# javascript

# array

Reaching members in Array with For Loop in JavaScript can be done in a number of ways, but the most common and basic way is to use traditional for loop (traditional for loop) or use for...Of the loop, sir.

1. Traditional use for Loop

This has long been a popular method and provides maximum control. Using an index (index) to reach each member:

JavaScript

const myArray = ["Apple," "Banana," "Cherry," "Date"];

/ / Loop through Array using Index

for (let i = 0; i < myArray.length; i + +) {

const element = myArray [i];

console.log ('Index ${i}: ${element}');

}

Description:

Let i = 0: Start the counter (index) at 0 (the index of the first member).

i < myArray.length: loop as long as the counter (i) is less than the total length of Array.

i + +: Increase the counter by 1 in each cycle.

myArray [i]: Use the i counter as an index to access members in Array.

2. Use of fors...Of Loop

Here's a more modern and cleaner method for looping in Array directly. Without using indexes:

JavaScript

const myArray = ["Red," "Green," "Blue," "Yellow"];

/ / Loop through Array with direct access to member values.

For (const element of myArray) {

console.log ('Value: ${element}');

}

Description:

For (const element of myArray): In each cycle of iteration, the element variable is configured directly to the next member in the myArray.

This method is only suitable for accessing the value (value) of the subscriber, but it is not convenient if you also want to access the index (index).

3. Use of fors...In Loop (Caution)

Although, ford...In is available, but generally not recommended for looping in Array because it loops through all the keys or property names of the object (including properties that may be added to Array) and may provide the wrong order.

JavaScript

const myArray = ["Alpha," "Beta," "Gamma"];

/ / Loop via Array using Keys (Index) - Not Recommended for General Array

For (const index in myArray) {

const element = myArray [index];

console.log ('Index ${index}: ${element}');

}

Instructions: Should use fors...In for looping in Object Properties, not Array.

2025/10/18 Edited to

... Read moreนอกจากเทคนิคการใช้ for loop พื้นฐานที่กล่าวมา ผมพบว่าการเลือกใช้วิธีชนิดของ loop สำคัญในการจัดการข้อมูลใน Array อย่างมีประสิทธิภาพ 1. ใช้ for...of loop เมื่อต้องการแค่เข้าถึงค่าใน Array โดยไม่สนใจตำแหน่ง index ทำให้โค้ดอ่านง่ายและเขียนรวดเร็ว 2. หากต้องการดัชนีควบคู่กับข้อมูล การใช้ traditional for loop ยังตอบโจทย์ดีที่สุด เพราะคุณสามารถเข้าถึง index และค่าได้พร้อมกัน 3. หลีกเลี่ยง for...in สำหรับ Array เพราะโค้ดอาจไม่ทำงานตามที่คาดคิดและเรียงลำดับผิดพลาด ซึ่งเคยเจอปัญหานี้ตอนแรกๆ นอกจากนี้ การใช้ forEach หรือเมธอดอื่นๆ ของ Array ก็เป็นอีกทางเลือกที่สะดวกเมื่อทำงานกับข้อมูลจำนวนมากและต้องการความกระชับ สำหรับตัวอย่างโค้ดใน OCR ที่แสดงการใช้ for...of เพื่อแสดงค่าสี เราสามารถปรับใช้รูปแบบนี้กับ Array ที่มีชื่อสิ่งของหรือข้อมูลต่างๆ ได้เช่นกัน โดยผลลัพธ์จะออกมาอ่านง่ายและดูแลได้ง่ายเมื่อโปรแกรมซับซ้อนขึ้น สุดท้าย การเข้าใจโครงสร้างและชนิดของ loop จะช่วยให้เราสามารถเลือกใช้ได้เหมาะสมกับสถานการณ์ ช่วยลดบั๊กและเพิ่มประสิทธิภาพให้กับโปรเจกต์ JavaScript ของคุณได้จริงๆ

Related posts

Semantic HTML
Did you know that using Semantic HTML makes your website more accessible, improves SEO, and enhances user experience? #webaccessibility #semanticHTML #webdevelopment #webdesign #frontenddevelopment
Aysha

Aysha

4 likes

How I’d Learn JavaScript If I Were Starting Again
#javascript #coding #programming #tech #codingforbeginners
Aysha

Aysha

124 likes

A young woman works on a MacBook laptop, with the text 'free coding bootcamps' overlaid. The image is from Lemon8, featuring the user @hannahshirley.
A MacBook displays the freeCodeCamp website, showing 'Learn to code - for free' and mentioning jobs at Google, Microsoft, Spotify, and Amazon. The site offers certifications.
A MacBook displays The Odin Project website, featuring 'Your Career in Web Development Starts Here' and highlighting its free full-stack curriculum supported by an open-source community.
Learn how to code with these FREE Bootcamps! 👩🏻‍💻
I’ve worked in EdTech for a majority of my career and one of the top skills I see people wanting to learn is coding. Not only do I see students taking this interest, but also people well established in their careers who may want to learn coding for purposes of switching industries or even building
hannah 💟

hannah 💟

455 likes

A table comparing Web API support across Chrome, Safari, Firefox, and Edge browsers. It details support for APIs like WebUSB, Web Serial, Web Bluetooth, WebHID, Web MIDI, WebGPU, ServiceWorker, Web Authentication, and Filesystem Access, indicating compatibility with checkmarks and crosses.
Web browser API support
Web browser APIs are standardized programming interfaces built into browsers that allow web apps to interact with system capabilities like local storage, multimedia, hardware access, graphics rendering, and authentication This chart compares the support of modern Web APIs across major browsers 😎
Learn Linux with Dan

Learn Linux with Dan

4 likes

Best - FREE - coding sites
learning to code is important and a great look for your resume! plus it’s fun! ANYONE CAN LEARN! these are my favorite sites I’ve utilized to learn new skills! #codinggirl #codingforbeginners #embracevulnerability #shareyourthoughts #Lemon8Diary
LOLLIPOPAK

LOLLIPOPAK

2980 likes

Delete half your terminal tabs - this one dashboard runs your whole fleet of coding agents at once. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

Learn Coding the Easy Way!
#LearnToCode #CodingTutorials #ProgrammingForBeginners #TechEducation #CodeWithMe
InsightEvolution

InsightEvolution

2 likes

An infographic illustrates web browser fingerprinting, categorizing attributes collected to create unique user profiles. It lists HTTP headers, input/interaction, browser config, system/device info, network connectivity, graphics/rendering, capabilities, and behavioral/timing data points.
Web browser fingerprinting
Web browser fingerprinting is the technique of uniquely identifying and tracking a device by collecting and correlating its exposed system, browser, and network attributes during web interactions Here are a categorized list of attributes collected as part of browser fingerprinting 😎👆 #privacy
Learn Linux with Dan

Learn Linux with Dan

17 likes

A man with tattoos and a cap sits at a desk, coding on a large monitor in a dimly lit room. Text overlays read 'SWIPE', 'Learning JavaScript?', and 'This is for YOU!', with a thinking emoji, promoting coding education.
A man with headphones and a cap codes at a desk with a large monitor displaying code. Text overlays read 'SWIPE', 'Break vs Continue', and 'In JS loops', with a thinking emoji, highlighting JavaScript loop concepts.
A man with headphones and a cap sits at a desk, coding on a large monitor in a bright room. Text overlays read 'Let's Discuss!' with a thinking emoji, inviting interaction about coding topics.
Coding W/ JavaScript?
As a software engineer w/ ADHD, understanding the difference between certain syntax keywords is critical, such as ‘continue’ and ‘break’ within JavaScript loops.💡 It’s almost like centering a <div> — it takes practice to feel confident in your abilities. 🛠️ When my mind gets stuck in a
Michael Burbank

Michael Burbank

13 likes

Microsoft just put their entire AI engineering curriculum on GitHub, for free, and it's better than most paid bootcamps. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

My Programming Interest Just Skyrocketed! 🚀
I just discovered something that has made my interest in programming explode to 1000000000000000%! 🤯 🎮 Learning Programming is Like a Game Adventure! From Python, Java, JavaScript, to HTML, there are all kinds of programming languages available, along with systematic topic courses. The learning p
Valder

Valder

2175 likes

A desk setup with a computer monitor and keyboard displays the title "FREE ONLINE CERTIFICATIONS to boost your resume" for 2023, with a Lemon8 watermark.
A laptop screen shows the Hubspot Academy website, detailing the free Inbound Marketing Certification course with options to sign up via Google or Microsoft.
A laptop screen displays the Google Skillshop website, showcasing various Google Ads Certifications with options to learn, apply skills, and get certified.
FREE Online Certifications 2023 💻
Boost your resume with these FREE online certifications! You can add them to your resume or LinkedIn profile, discuss them in an interview or just use them to upskill and reskill yourself to keep pace with today’s ever-changing economy. ‌> Hubspot’s Inbound Marketing Certification: Gain kno
hannah 💟

hannah 💟

11.3K likes

Delete IDM - this open-source downloader chunks files without merging them, adds AI acceleration, and it's still free. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

Show on scroll website
Sample website with smooth scrolling and content showing on,y when is on screen. #CSS #html #javascript #webdevelopment
The Digital Mike

The Digital Mike

1 like

penny

penny

0 likes

This one repo replaces your LangChain glue code, your vector DB dashboard, and your agent framework - all at once, and it's free. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

A laptop screen displays lines of code, with text overlayed saying 'free websites to learn coding' and 'new skill,' encouraging users to swipe for more information on learning to code during a study break.
A laptop screen shows code, overlaid with a pop-up featuring 'codecademy.com.' The pop-up highlights interactive coding courses and a sign-up form, promoting it as a free resource for learning various programming languages.
A laptop screen displays code, overlaid with a pop-up featuring 'freecodecamp.com.' The pop-up describes it as a nonprofit offering free comprehensive web development and data analytics curriculum, including certifications.
On a study break? Try to learn how to code! 👩🏻‍💻
Learning coding during a study break is a productive way to use your time. It provides a mental shift from regular studies, enhances problem-solving skills, and fosters creativity. Online coding platforms offer flexibility, allowing you to learn at your own pace. This makes coding an ideal acti
teal.days

teal.days

2486 likes

Make Your Visitors Click!
Day 7 of HTML + CSS in Action! Today we’re creating a clean Call-to-Action Banner with a bold message and a button. Perfect for portfolios, blogs, or landing pages. #HTMLCSS #WebDev #LearnToCode #CallToAction #codewithaysha
Aysha

Aysha

0 likes

A day in the life of a Software Engineer 👩🏽‍💻 #dayinthelife #softwareengineer #bigtech #womenintech #blackgirlmagic
Faïkat M.

Faïkat M.

29 likes

A desk setup with two monitors displaying C++ code, featuring a "C++ Cheat Sheet For Beginners" title overlay. The left screen shows nested switch statement code, while the right screen displays more code. A keyboard and mouse are visible, with a Lemon8 watermark in the corner.
C++ Cheat Sheet For Beginners
Follow for more as I almost finish c++ 🫶🏽 #womeninstem #cplusplus #compsci #stem #student
Kailey

Kailey

1 like

It may or may not depend on your effort.🫡
It sounds contradictory but everyone has their perfect time to learn new frameworks, so do not despair and do it without fear but with patience 😎 #lemon8diarychallenge #webdevelopment #programmer
Feibertord ⚡️

Feibertord ⚡️

15 likes

A dark blue background with the title "6 DISCORD COMMUNITIES EVERY CODER SHOULD JOIN!" in white text. Below it, a white computer monitor displays a blue Discord logo, with a yellow star next to it. The bottom reads "Don't miss out!".
A dark blue slide detailing "The Coding Den" Discord community. It highlights its focus on general programming, help, projects, and career advice, and reasons to join, such as being beginner-friendly and having supportive moderators. A join link is provided.
A dark blue slide detailing the "Python Discord" community. It focuses on Python programming and related technologies, emphasizing it's the official Python community with regular events and challenges. A join link is provided.
6 Discord Communities Every Coder Should Join!
#coding #learncoding #discorddev #webdeveloper #techcommunity Whether you're learning HTML, CSS, JavaScript, Python, or diving into full-stack development — these Discord servers are filled with devs, mentors, and resources to support your coding journey. 👩🏽‍💻👨🏿‍💻 👇 Tap to joi
Aysha

Aysha

10 likes

A dark image showing code on a screen and a keyboard, with text overlays "Top 10 Free Online Courses with Certificates" and "SWIPE FOR MORE," indicating a list of educational resources.
A collage of four logos for online learning platforms: Google Digital Garage, Harvard University, Coursera, and LinkedIn Learning, highlighting various educational opportunities.
A collage of four logos for online learning platforms: Alison, The Open University, a green hexagonal logo with a figure and leaves, and a purple upward-pointing arrow logo.
Top 10 Free Online Courses W/ Certificates
With me having no friends😅 I try and find resourcesful tool and reasouces I can use to better myself in difficult skill aspects! I’ve actually tried a couple of these and currently using Udemy rn! It’s never ending courses. Here’s details on each website! Would you try and of these? Also this is my
Iamnariah

Iamnariah

13.3K likes

Seventy-six thousand stars for a coding agent that runs on your own machine, with your own login, doing whatever your login can do. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

A CodeSignal certificate awarded to Cuong Lam Kim Huynh for successfully completing the 'Introduction to JavaScript for Front-End Engineers' course, part of the 'Comprehensive Introduction to Front-End Engineering' learning path, covering JavaScript Programming and DOM API, dated January 13, 2025.
Huỳnh Lam Kim Cường

Huỳnh Lam Kim Cường

0 likes

Evony Nard

Evony Nard

0 likes

It’s all about the motion learn how they move before you learn why
Evony Nard

Evony Nard

1 like

Someone built the frontend review system that paid audit tools have been faking, and it's completely free. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

Tech jobs you can do without prior experience 🖥️
🖥️ 👩‍💻Web Developer : Build and maintain websites, ensuring they are functional, user-friendly, and visually appealing. Work with front-end and back-end technologies like HTML, CSS, JavaScript, and databases. 💰 Starting Salary: $55,000 - $65,000 per year 📊📈 Data Analyst: Analyze and interpret
vedha | career tips (tech) 👩‍

vedha | career tips (tech) 👩‍

3624 likes

Someone built a self-hosted Cursor alternative that runs Claude Code, Codex, and Gemini - from the same dashboard, on your own machine. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

koala73/worldmonitor - Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

JavaScript Cheat Sheet
Essential JavaScript commands every developer needs! 🚀 Variables, functions, loops, arrays & DOM manipulation all in one quick reference guide. Perfect for coding interviews or daily development. Save this for later! 💾 #JavaScript #WebDev #Programming #Coding #Developer #JS #CodeTips
EM

EM

2 likes

Someone built a full private ChatGPT that runs on your own machine, and sixty-four thousand people have already starred it. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

How to Learn Coding Fast Even as a Beginner
#codingforbeginners #programming #studymotivations #webdevelopment #learntocode
Aysha

Aysha

801 likes

Grammarly wants your writing sent to their servers, and that alone should bother you more than it does. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

Huỳnh Lam Kim Cường

Huỳnh Lam Kim Cường

0 likes

JavaScript Cheat Sheet
Essential JavaScript commands every developer needs! 🚀 Variables, functions, loops, arrays & DOM manipulation all in one quick reference guide. Perfect for coding interviews or daily development. Save this for later! 💾 #JavaScript #WebDev #Programming #Coding #Developer #JS #Code
EM

EM

1 like

An illustration showing a global network of diverse people's faces connected by lines, with a hand holding a smartphone displaying a thumbs-up icon and other social media symbols, representing online tech communities.
A screenshot of the AnitaB.org website, highlighting its mission to pave the way for women and nonbinary individuals in tech, featuring sections on career development, events like GHC, and membership.
A screenshot of the Baddies in Tech website, featuring a woman with a laptop and promoting itself as a safe space and professional development community for women of color in tech.
Online Tech Communities for Aspiring and Pro Devs
Even lone wolves interact with other wolves from time to time, so why not you, dev who codes alone for hours on end? Here are some communities and organizations you might be interested in joining so you can meet new people. AnitaB.org For women and non-binary people in tech, for all career leve
Karelle

Karelle

3 likes

🎓 Websites That Teach You For Free 🎓
Ready to level up your tech skills without spending a dime? Here's a list of websites offering free courses across various fields. Let's get started! 🚀 🤖 Artificial Intelligence (AI) • http://elementsofai.com • http://lnprogrammer.com 🌐 Web Development HTML • http://html.com • ht
Valder

Valder

203 likes

W3Schools
This page has been the best think that could happen to me while taking my C++ course 🙏 #educateyourself #education #knowledge #stemstudent #Lemon8
Labelle

Labelle

5 likes

HTML + CSS + JavaScript = MAGIC! 🔥
HTML alone is just a structure, CSS adds style, but JavaScript brings it to life! 🚀 Watch how I build this Digital Clock from scratch using HTML, CSS & JavaScript! 👨‍💻💡 Try it yourself & level up your coding skills #codingforbeginners #htmlcssforbeginners #studymotivation #learntocod
Aysha

Aysha

3 likes

Did you know??
That your phone logs your websites you visit even if they are deleted? Here I’m going to teach you how to access your website data, so that you can check and delete both yours (and others😉🤪) website history. #relationshiptips #Couple #toxicrelationship #Lemon8 #christmas
Kristin🔆🔍

Kristin🔆🔍

53 likes

A person's hand is on a MacBook Pro keyboard, displaying the coddy.tech website with "Code Makes Perfect" and coding illustrations. The image highlights learning to code for free with this website.
A MacBook Pro screen shows the coddy.tech website's daily challenge interface, allowing users to search by programming language, choose difficulty, and access daily challenges.
A MacBook Pro screen displays the coddy.tech website, showcasing full, beginner-friendly courses like "SQL for beginners" and "Python Introduction," emphasizing practicing at one's own pace.
learn how to code for FREE! 💻
learning to code for free has never been easier with coddy.tech! 🌟 whether you're a complete beginner or looking to enhance your skills, coddy.tech offers a range of resources to help you on your coding journey. here's how you can get started: explore coding courses: coddy.tech provides
sanae ☕️

sanae ☕️

1411 likes

Microsoft just dropped a free eighteen-lesson course on building AI agents, and seventy-one thousand people have already starred it. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

A young woman with long dark hair, wearing a pink satin shirt, smiles at the camera while sitting at a table. Overlay text reads: 'Tools and sites I use as a cybersecurity student to progress my skills and keep me interested in studying'.
A screenshot of 'The Hacker News' website, displaying various cybersecurity news articles from January 2025, including topics like vulnerabilities, malware, cyber espionage, and AI jailbreak methods. An ad for Zscaler and a banner for CIS Hardened Images are also visible.
A screenshot of the O'Reilly learning platform, showing various books and expert playlists related to AI, engineering, and data. Overlay text highlights the subscription cost ($50/month or $499/year) and its value for accessing books and live events.
Tools and sites I use as a cybersecurity student 🌸
#cybersecuritystudent #cybersecurity #techgirlie
LexiStudies

LexiStudies

113 likes

HTML Cheat Sheet
Essential HTML tags every developer needs! 🚀 Quick reference guide covering structure, text, links, images, forms & more. Perfect for beginners and coding bootcamps! Save this for your next project 💻✨ #HTML #WebDevelopment #Coding #Programming #webdev
EM

EM

1 like

Grab Attention with a Hero Section
Day 6 of HTML + CSS in Action! Today we’re creating a bold hero section with a heading, text, and button. Perfect for portfolios, landing pages, and websites #HTMLCSS #LearnToCode #Frontend #HeroSection #codewithaysha
Aysha

Aysha

6 likes

Someone built NotebookLM and ChatGPT Enterprise, but it runs on your own machine and the source code is right here. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

A CodeSignal certificate awarded to Cuong Lam Kim Huynh for successfully completing the 'Mastering the DOM API' course, part of the 'Comprehensive Introduction to Front-End Engineering' learning path, dated January 14, 2025.
Huỳnh Lam Kim Cường

Huỳnh Lam Kim Cường

0 likes

Day 2 introduces JavaScript variables, depicted as a box storing `let name = "Aysha";`. The image encourages learning to store and manage data like a pro, setting the stage for understanding variables in programming.
This image defines a variable as a box holding information. It visually represents `name = "Aysha";` with "name" as the variable name on the box and "Aysha" as the value inside, illustrating the concept clearly.
Explaining why variables are used, this image shows `userName`, `city`, and `age` variables storing data like "Aysha", "New York", and 26. It highlights their role in reusing data within code.
What Are Variables in JavaScript
In JavaScript, variables are like boxes that store information such as a user’s name, city, or age. We use them to make our code flexible and reusable. #CodeWithAysha #JavaScriptForBeginners #LearnJavaScript
Aysha

Aysha

3 likes

HTML Tags You Didn’t Know Exist
#htmlforbeginners #codingjourney #codingforbeginners #webdesigntips #softwareengineering
Aysha

Aysha

32 likes

Roadmap to Becoming a Frontend Developer
Want to break into frontend development but don’t know where to start? 🤔 This step-by-step roadmap will guide you from beginner to job-ready frontend developer! #codingforbeginners #htmlcssforbeginners #programming #studymotivations #softwareengineer
Aysha

Aysha

52 likes

Someone just open-sourced the document intelligence layer that enterprise RAG companies charge thousands a month for. #github #opensource #coding #tech #ai
Kirbyhatguytech

Kirbyhatguytech

0 likes

See more