Important Notice:

Type Casting Conversion

Type Casting Conversion

23 views 1 min read

Type Casting Conversion:

  1. Number() – मान को Number (संख्या) में बदलना
  2. parseFloat() – String को दशमलव (Float) संख्या में बदलना
  3. parseInt() – String को पूर्णांक (Integer) में बदलना

Example combined:-

<!DOCTYPE html>
<html>
<body>

<script>
  let mixed = "42.75px";
  
  console.log(Number(mixed));    // NaN
  console.log(parseFloat(mixed)); // 42.75
  console.log(parseInt(mixed));   // 42
</script>

</body>
</html>

Related Notes