This may be a strange question. I'm trying to fuse two arrays together, but the read out is showing them as separate types of objects. The first type, gathered by the .serializeArray() jquery function is showing as this when I alert them:
[object Object]
The second, which I am getting from pushing each option in using a more JS way, shows as this:
[object HTMLOptionElement]
Here's my code below:
incrCopy();
enableSubmit();
disableReset();
var linkedInArray = [];
$('form select option.linked-in').each( function() {
linkedInArray.push(this);
})
//These alert the second way
prevVals = $("form").serializeArray();
//They alert the first way
prevVals.push(linkedInArray);
alert(prevVals);
Anyone have an idea on what I'm missing here?
$()serializeArraycollects the values from the form fields and creates an array of objects (api.jquery.com/serializeArray).linkedInArray.push(this);directly adds the DOM element to the array. You are just doing two different things.console.log, andconsole.dirvia the developer console than you ever will viaalert.