Runtime Type Error Example

JavaScript allows operations with unexpected types which may cause runtime errors.

Preview

Code

<script>
function add(a,b){
  return a + b;
}

console.log(add(5,10));
console.log(add("5",10)); 
</script>

More Why JavaScript Needs Type Safety Examples (2)