What does this JavaScript snippet mean? The (evt) part is so confusing; evt is not a boolean. How it works?
function checkIt(evt) {
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
}
evt = (evt) ? evt : window.eventis just the inlineifsyntax. It’s equivalent to this code:If
evtis truthy,evtwill be left alone. Ifevtisn’t truthy, it will be replaced withwindow.event.