checked = "checked" vs checked = true
html, javascript
Solution
`document.getElementById('myRadio').checked` is a boolean value. It should be `true` or `false`
`document.getElementById('myRadio').checked = "checked";` casts the string to a boolean, which is true.
`document.getElementById('myRadio').checked = true;` just assigns `true` without casting.
Use `true` as it is marginally more efficient and is more intention revealing to maintainers.
Problem
What is the difference between the below two usages? ``` document.getElementById('myRadio').checked = "checked"; ``` and ``` document.getElementById('myRadio').checked = true; ``` For me, both are behaving the same way. But, I am just curious to know why there exist two methods to do the same. Which one will be the ideal usage? I need to support IE7 and higher versions.