I am quite new to JavaScript, and so am still coming into small things that I don’t quite understand and don’t seem to appear when I search for them.
Please could somebody point me out what the ? : syntax is doing below.
var chCode = ('charCode' in event) ? event.charCode : event.keyCode;
This is called the ternary operator. It’s a short
if...elsestatement.Basically, your code can be expanded to this.