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 8251619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:17:48+00:00 2026-06-08T00:17:48+00:00

I am kind of confusing about the jquery.map function. I have an array say

  • 0

I am kind of confusing about the jquery.map function.

I have an array say myArray = ["1", 3, "a", 5].

Can I use $.map().get().join(',') to get result of [1, 3, 5];

$(myArray).map(function() { 
    if (!isNaN(this)){  
        return this
    }       
}).get().join(',');

the above code return ["1","3","a","5"]

http://jsfiddle.net/kkgian/khurZ/

TIA

  • 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-06-08T00:17:50+00:00Added an answer on June 8, 2026 at 12:17 am

    .map() does not alter the original array. Because your code does not capture the value returned, you’re just throwing it away.

    Use the (poorly-named) $.grep function instead of .map(). Thanks to the invert argument, you don’t even have to use an anonymous function; you can use isNaN directly as the predicate.

    var filteredArray = $.grep(myArray, isNaN, true);
    

    http://jsfiddle.net/mattball/nzeBZ/

    N.B. isNaN('1') returns false because '1' is a string that can be reasonably coerced to a number. If that’s not acceptable, use a better filter predicate. It’s a little unclear if you actually want an array of numbers, or just the string '[1, 3, 5]', however.

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

Sidebar

Related Questions

Kind of like this question I have many text snippets that I use many,
I'm currently writing JavaScript and confusing about callback . I've found it's not kind
@font-face is kind of confusing as all the browsers cannot decide on a single
I'm working on this homework that's kind of confusing me... I am provided with
Kind of a follow up to a question from yesterday. I have a hash
be kind this is my first post. I have a Crop intent retuning and
before answer me plz thinking about the futures of these kind of program and
PDO and prepared statements are still kind of confusing to me, no matter how
In LunarLander sample game provided as android sample game, I have a confusion about
I have NOT done much of web-developing and I would like to learn about

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.