JavaScript Error name Property TypeError

Introduction

TypeError: A type error has occurred

You cannot convert a number to upper case:

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>

<script>
var num = 1;/*  www . j  a  va 2  s  . c om*/
try {
  num.toUpperCase();
}
catch(err) {
  document.getElementById("demo").innerHTML = err.name;
}
</script>

</body>
</html>



PreviousNext

Related