Static Types(set during development)
function add (n1:number, n2: number) {
return n1 + n2;
}
const result = add(39, 28);
Dynamic Types(resolved at runtime)
function add(n1, n2) {
if(typeof n1 !== 'number' || typeof n2 !== 'number') {
throw new Error('Incorrect input!');
}
return n1 + n2;
}
const result = add(39, 28);