var send_value = [current_site_id, current_site_name, current_site_description];
console.log(send_value);
send_value = jQuery(this).is(':checked') ? send_value.push('add') : send_value.push('delete');
console.log(send_value);
The result is
[“12”, “qwrqweqwer”, “qwreqwr”]
4
Where i’m wrong?
PS.
Sorry, my mistake was in send_value =, can not understand how it got there
This line
send_value = jQuery(this).is(':checked') ? send_value.push('add') : send_value.push('delete');assigns the return value ofpushtosend_value, it doesn’t push anything. The return value is the new length of the array object, as you can see in the specificationsTry this:
Push the resulting value of your ternary
If you find it more readable, you could turn your ternary into an expression, rather then a statement:
But, frankly, if your concerned about readability, it’s best to do away with ternaries all together IMHO.