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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:10:56+00:00 2026-06-04T07:10:56+00:00

I am having trouble deleting this (a specific ‘event’) from the following javascript object,

  • 0

I am having trouble deleting this (a specific ‘event’) from the following javascript object, when this is from a jquery .each() loop.

weatherData:

{
    "events":{
        "Birthday":{
            "type":"Annual",
            "date":"20120523",
            "weatherType":"clouds",
            "high":"40",
            "low":"30",
            "speed":"15",
            "direction":"0",
            "humidity":"0"
        },
        "Move Out Day":{
            "type":"One Time",
            "date":"20120601",
            "weatherType":"storm",
            "high":"80",
            "low":"76",
            "speed":"15",
            "direction":"56",
            "humidity":"100"
        }
    },
    "dates":{
        "default":{
            "type":"clouds",
            "high":"40",
            "low":"30",
            "speed":"15",
            "direction":"0",
            "humidity":"0"
        },
        "20120521":{
            "type":"clear",
            "high":"60",
            "low":"55",
            "speed":"10",
            "direction":"56",
            "humidity":"25"
        }
    }
}

This is a shrunken version of the .each() loop:

$.each(weatherData.events, function(i){
    if(this.type == "One Time"){
        delete weatherData.events[this];
    }
})
  • 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-04T07:10:57+00:00Added an answer on June 4, 2026 at 7:10 am

    You’re using an object where a string (the property name) is expected. I believe you want:

    $.each(weatherData.events, function(i){
        if(this.type == "One Time"){
            delete weatherData.events[i];
            // change is here --------^
        }
    });
    

    …because $.each will pass in the property name (e.g., "Move Out Day") as the first argument to the iterator function, which you’re accepting as i. So to delete that property from the object, you use that name.

    Gratuitous live example | source

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

Sidebar

Related Questions

I am having some trouble deleting documents from Solr index. I use following code:
I'm having trouble deleting/removing an item from an Array in jQuery. I've run the
Having trouble with this jQuery function: $(#content).siblings().each(function(i){ heightOfSiblings = heightOfSiblings + this.outerHeight(); }); Error
I am having trouble deleting rules from the stylesheet object due to ever changing
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
Having trouble getting the javascript alert to display from my code behind. c# -
I am having trouble deleting orphan nodes using JPA with the following mapping @OneToMany
I'm having some trouble deleting an item from a collection inside a model when
I am having trouble deleting multiple konkurrancers with checkboxes. I get this error in
I am having trouble deleting orphan nodes using Hibernate with the following mapping @OneToMany(fetch

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.