eckhchri / pcars-ds-liveview

Provides a html page for project cars dedicated server and display a map of the current race.
14 stars 1 forks source link

Change MyArray.length() to new method #22

Open eckhchri opened 9 years ago

eckhchri commented 9 years ago

root cause looks like problem within webworlker enviroment.

Workaround:

convert object to an array: http://api.jquery.com/jQuery.makeArray/ JQuery: isArraylike(obj) Test if its an array: http://jsfiddle.net/kflorence/JUxZA/

Check type of vars via

Possible Solution: Object.keys(myObject).length // seems to be working in Firefox and Chrome but not MS Edge

Examples, with different result in FireFox and Chrome for "aTrackList = new Array()": Object.keys(aTrackList).length aTrackList.length

1.) Change for to foreach (http://stackoverflow.com/questions/10563251/length-of-a-javascript-associative-array )

2.) http://api.jquery.com/jquery.each/ 3.) in cases of using "if (aTrackList.length != 0)": https://msdn.microsoft.com/library/d8ez24f2%28v=vs.94%29.aspx array.length() did not provide the number of entries

http://www.shermann.name/2010/11/firefox-and-chrome-different-javascript.html

  1. The proper way to loop over an array in javascript is: myArray.forEach( function( i ){ console.log( i ); });