Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7509575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:57:27+00:00 2026-05-29T22:57:27+00:00

given an array of objects l = [a,b,c,d] l.map(function(x){x.zop({foo:bar})}) is this a bad idea?

  • 0

given an array of objects

l = [a,b,c,d]

l.map(function(x){x.zop({foo:bar})})

is this a bad idea?

i mean it works and all 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:57:29+00:00Added an answer on May 29, 2026 at 10:57 pm

    Yes, it is perfectly fine to use array iteration functions and I personaly try to use them whenever I can instead of a for loop. The main reasons I do so are:

    • No need to declare useless variables (like the loop counter) that clutter the code and confuse my JSHint.

    • I need to write down the array only once. This makes it easier to rename the array variable if I want to and it is also more amenable to passing an expression directly (instead of having to save the array in aother extraneous variable)

    • Regular for loops are vulnerable to the closures-inside-for-loops bug.

    Do remember though that map, forEach and friends are not present in older browsers (particularly, Internet Explorer) so you should either use a shim (to add these methods to the native arrays) or use similar functions from a custom library.

    edit: nowadays you should feel free to use these functions. If you still need to support IE8 you have bigger problems than this…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an array of n Objects, let's say it is an array of strings
I have a string. I need to replace all instances of a given array
How do I run the PHP function htmlspecialchars() on an array of array objects?
I would like to map a given array index into a property with RestKit
question origin Given an unsorted array of size n containing objects with ids of
Given a mapping program where I map from an array of strings to a
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given var myHash = new Array(); myHash['key1'] = { Name: 'Object 1' }; myHash['key2']
Given an array of characters which forms a sentence of words, give an efficient
Given an array of integers, what is the simplest way to iterate over it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.