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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:35:13+00:00 2026-06-11T15:35:13+00:00

I am working on javascript project where I have 2 arrays 1. elements 2.

  • 0

I am working on javascript project where I have 2 arrays 1. elements 2. elementsOrder ; elementsOrder array contains the names of each element, and elements array contains all properties of each element. When I want to delete one element from each array I do it with “delete” build in function, but it doesn’t deletes element only sets it to Undefined, so than I use splice method to push out those undefined elements, but it doesn’t work.

the is the source:

var s1 = elementsOrder.indexOf(id);
delete elements[s1];
delete elementsOrder[s1];

it does the job and sets elements one by one “undefined” smoothly, but when I do:

var s1 = elementsOrder.indexOf(id);
delete elements[s1];
delete elementsOrder[s1];
elements.splice(s1, 1);
elementsOrder.splice(s1, 1);

using simply splice methods don’t work:

var s1 = elementsOrder.indexOf(id);
elements.splice(s1, 1);
elementsOrder.splice(s1, 1);

I use this piece of code in my Javascript Canvas project to animate some canvas objects, so I can easily see when “delete” works smoothly and “undefines” elements one by one, and splice doesn’t works so smoothly and doesn’t puts out elements one by one

Please see http://jsfiddle.net/7ZuuZ/ pay atantion to function animate, third function from bottom

  • 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-11T15:35:15+00:00Added an answer on June 11, 2026 at 3:35 pm

    Why not just splice in the first place?

    var s1 = elementsOrder.indexOf(id);
    elements.splice(s1,1);
    elementsOrder.splice(s1,1);
    

    There is no need to delete here.

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

Sidebar

Related Questions

I am working on a javascript project which involves parsing xml data. I have
I'm working on a security project in Javascript (something I honestly have not used),
I'm working on a project and trying to use JavaScript for validating all inputs
Hello all I am working on javascript jquery and svg.I want to ask a
I am currently working on a php/html/javascript project. I have a form where when
I am working with JavaScript for a project where I have been using a
I am working on a php+javascript based project and have already made up a
I'm working on a new project in JavaScript that I want to release later.
I'm currently working on a JavaScript project that uses the HTML5 canvas as a
while working on a school project i ran into a problem using javascript to

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.