!= non-null assertion operator (this expression cannot be null or undefined)
const input1 = document.getElementById("num1")! as HTMLInputElement
The above says, find this element I know is not null, and I know is an HTML Input element.
ts adds tuples which are fixed-length arrays.
let x: [number, string] = [10, "foo"]
typescript can't catch using
x.push()as a type error.
protectedenables accessing properties from inherited classes in child classes (whereas
abstractclasses (and methods) are used to force all future-inheriting classes to re-define how a method should look / work for each individual class.
constructorcan be made into a
private constructor. This prevents the use of instantiating via
You could then create a private static property on a class ... of the class itself.
then create a static method of
getInstancewhich will return the instance.