Answer the question
In order to leave comments, you need to log in
Bugs in JavsScript?
I recently came across a problem with arrays in JS. I won't post the code because it's big.
But why in JS it is sometimes impossible (not possible) to add a push object to the array. It's just not added and that's it!!! I can't fake anything. What could be the errors. The flags are by default.
Answer the question
In order to leave comments, you need to log in
Check if you have an array there:
// ранее: var something = ... ;
if( Array.isArray( something) console.log( 'isArray: true' );
if( something instanceof Array) console.log( 'instanceof: true' );
if( Object.prototype.toString.call( something ) === '[object Array]' ) console.log( 'toString: true');
if( something.constructor === Array) console.log( 'constructor: true');
Objects are always easily added to an array. If this does not happen, then:
1. There may be an error in the code BEFORE adding the object, so code processing stops earlier
2. Array.prototype.push may be overridden by some of the scripts
3. You may be confusing an array with a NodeList.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question