In my code, there is a function that accepts only numeric variables.
function add(n1: number) {
return n1 + n1;
}
However, I mistakenly initialized a variable with type "any" and assigned it a string value of '5'.
let number1;
number1 = '5';
I was surprised to see that no error was thrown when passing this string variable to the function.
console.log(add(number1));
(As expected, the result is 55 as the string gets concatenated instead of added.)