JavaScript type...LOGIN

JavaScript type conversion

JavaScript Type Conversion

Number() is converted to a number, String() is converted to a string, and Boolean() is converted to a Boolean value.

JavaScript Data Types

There are 5 different data types in JavaScript:

string

number

boolean

object

function

3 object types:

Object

Date

Array

2 A data type that does not contain any value:

null

undefined

typeof operator

You can use the typeof operator to view the data of a JavaScript variable type.

 <html>
<body>
<script type="text/javascript">
var test=new Array();
if (test.constructor==Array)
{
document.write("This is an Array");
}
if (test.constructor==Boolean)
{
document.write("This is a Boolean");
}
if (test.constructor==Date)
{
document.write("This is a Date");
}
if (test.constructor==String)
{
document.write("This is a String");
}
</script>
</body>
</html>
Next Section
<html> <body> <script type="text/javascript"> var test=new Array(); if (test.constructor==Array) { document.write("This is an Array"); } if (test.constructor==Boolean) { document.write("This is a Boolean"); } if (test.constructor==Date) { document.write("This is a Date"); } if (test.constructor==String) { document.write("This is a String"); } </script> </body> </html>
submitReset Code
ChapterCourseware