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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:00:50+00:00 2026-06-14T11:00:50+00:00

I try playerNameArray.length = 0; this doesn’t empty the array, it makes those values

  • 0

I try playerNameArray.length = 0; this doesn’t empty the array, it makes those values be undefined.

I try playerNameArray = []; this doesn’t empty the array, it makes those values be undefined.

I try var playerNameArray = new Array (); this doesn’t empty the array, it makes those values be undefined.

Maybe the problem is the initial array is public and i try to empty them inside of functions?

Maybe the problem is I need that array to be public in my JavaScript because on my html page I pass the array in a function and the page wont recognize the array if I initialize it inside the function I use it?

I add each array object to a database, but a user should be able to create a new array after inserting the first one. I tried to cheese my insert statement and said if the array element != ‘undefined’ then insert it but it completely ignored that and inserted the undefined.

any suggestions please?

the code is as follows:

var createListCounter = 0;
var playerID = new Array();
var playerNameArray = new Array();

function addToList(espnPlayerID, playerName) {
    playerID[createListCounter] = espnPlayerID; playerNameArray[createListCounter]                =playerName;
    createListCounter++
    var url = "";
    $('#accumListPlayer').append('<tr><td>'+ playerName + '</td></tr>');
}

then on a button click i iterate through that array and save it t oa db. once that completes, i need the array to have nothing in it. if i still have the original objects in it, they write to the database again.

  • 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-14T11:00:51+00:00Added an answer on June 14, 2026 at 11:00 am

    Setting it equal to [] or new Array() overwrites the current value with a blank array.

    If you are looping the array you can check if it has any elements by testing its length:

    if(playerNameArray.length > 0) // has at least one element
    

    You can also test individual elements of the array using the typeof function:

    if(typeof(playerNameArray[3]) == 'undefined')
    {
        // element 3 is undefined
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

try { JSONArray jArray = new JSONArray(result); for(int i=0;i<jArray.length();i++) { JSONObject json_data = jArray.getJSONObject(i);
Try this: Make a new XCode4 Applescript project. In the delegate, paste this code:
Try this: $test = array (2+2); var_dump($test); Then try the same but inside a
try { this.Invoke((MethodInvoker)delegate { Uri uri = new Uri(mywebpage.com); NetworkCredential credentials = new NetworkCredential(username,
Try to save them like this: HttpCookie latcook = new HttpCookie(latitude, lat.Value.ToString()); HttpCookie lngcook
try { $matrix = Query::take(SELECT moo); //this makes 0 sense while($row = mysqli_fetch_array($matrix, MYSQL_BOTH))
try { answerField.setText(Unscrambling...This may take a minute); BufferedInputStream(getAssets().open(wordlist.txt)); BufferedInputStream[] textfile = new BufferedInputStream[28]; for(int
try{ f = new ProjectFile(); numProject = f.getOutput(); String[] projectData = new String[numProject.length]; //retrieving
Try to debug this script. I think it maybe an issue of variable interpolation?
Try this in chrome versus firefox/IE: var cancelPressed = false; function redirect() { //window.location

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.