Create a string with the String constructor in JavaScript

Description

The following code shows how to create a string with the String constructor.

Example


<!--from  w w  w. j a v a2s .  com-->

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var stringObject = new String("hello world");
document.writeln(stringObject);
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create a string with the String constructor in JavaScript