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

  • SEARCH
  • Home
  • 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 6639707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:35:08+00:00 2026-05-25T23:35:08+00:00

I know this code is correct, I did not write it. I am trying

  • 0

I know this code is correct, I did not write it. I am trying to understand what the code is doing.

  1. create variable
  2. loop through unordered list’s children
  3. set cssClass = class name
  4. if the cssClass is not in myarray, add it to myarray

I am familiar with other ways to check to see if an item is in an array, and familiar with other ways to add an item to an array, but this method confuses me. Do other languages support this type of syntax?

    var myarray = [];
    $(".somelist > li").each(function() {
    var cssClass = $(this).attr("class");

    //This part below is CONFUSING
    if(!myarray[cssClass]) {
         myarray[cssClass] = true;
    }
});    
  • 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-25T23:35:09+00:00Added an answer on May 25, 2026 at 11:35 pm
    1 if(!myarray[cssClass]) {
    2         myarray[cssClass] = true;
        }
    

    Here’s a brief outline of what’s happening, the myarray variable is used as a hash –

    1 – Checks to see if the current class name is in the array. myarray[cssClass] will return a ‘falsy‘ value if the class name is not conatined in the array.

    2 – If the class is not in the array, add it to the array and set it’s value to true

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

Sidebar

Related Questions

according to this code i dont understand about NSClassFromString how did i know viewControllerName
Does anyone know why this code doesn't work. This means, the alert is NOT
I know this sort of code is not best practice, but nevertheless in certain
I have a sales simulator written in C#. I did not write this however
Hi I have this code in my view.. <%=Html.DropDownList(ProductTemplate,new SelectList(Model.ProductTemplate,Value,Text))%> I know if this
With this code function someFunction(classParam:Class):Boolean { // how to know if classParam implements some
I have this code and don't know if what I would like to achieve
I have this code, I know I'm missing something but don't know what. It
I'm reading this code sample : And since I don't know C#, I decided
Can anybody help with this code I just don't know where I am going

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.