Option change of select element

2

I'm trying to add an option to a select:

function add(){
    var opt = document.createElement("option");
    opt.value = "0101";
    opt.text = "foo";
}

This code works.

My question is why when I remove the double quotation marks from the line where I pass the value to the option does the value become 65?

    
asked by anonymous 22.04.2015 / 15:31

1 answer

2

@FelippeTadeu Javascript starts bit manipulation when it finds the value 0101 (which in 8bit ascii is equal to decimal 65);

When numbers / values that you want to assign to a non-variable are integers, or decimals ( 1.2 , pex)

  

I agree with you in parts, because if this code was written straight html you would be right, but this is being done in javascript. - Felippe Tadeu

This is right up to a point, as you can see in your code.

    
22.04.2015 / 16:01