I have just come across some behavior I have never seen before. The javascript in my html page is converting a boolean
to a string
I have a html page that looks like the following:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script type="text/javascript">
var status = true;
console.log(typeof status) //returns string
</script>
</body>
</html>
Strangely, when I open the console and type var test = true
; and then on the following like type typeof test
it returns "boolean"
.
Can anyone explain why this is happening and why it is not a boolean
on both occasions?