Javascript Data Type How to - Get String constructor








Question

We would like to know how to get String constructor.

Answer


<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
<!--  w ww .j ava2 s. c om-->
var str = "true";
if ((str.constructor == String) && (str.toLowerCase() == "true")) {
    document.writeln("OK");
}

</script>
</body>
</html>

The code above is rendered as follows: