Create String from null in JavaScript

Description

The following code shows how to create String from null.

Example


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var s1 = String(null);    //"null"
document.writeln(s1);
<!--from   w  ww  .  j a  v a  2  s . com-->
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create String from null in JavaScript
Home »
  Javascript Tutorial »
    Data Type »
      String
...
Compare a char value in if statement in Jav...
Compare a string based on locale informatio...
Compare the char value in JavaScript
Compare two strings in JavaScript
Concatenate one or more strings to another ...
Convert Number to String with toString meth...
Convert boolean to String in JavaScript
Convert boolean to string with String() in ...
Convert null to string with String() in Jav...
Convert number to string in radix in JavaSc...
Convert number to string with String() in J...
Convert string to lower case based on local...
Convert string to lower case with toLowerCa...
Convert string to upper case based on local...
Convert string to upper case in JavaScript
Convert undefined to string with String() i...
Convert value to String with toString metho...
Count the words in JavaScript
Create String from null in JavaScript
Create String object by calling its constru...
Demonstrate that all negative numbers are c...
Divide string into several parts with Strin...
Escape a string with escape function in Jav...
Find all occurrences for the sub string wit...
Get sub string with String substr() method ...
Get sub string with string substring method...
Get substring from the end of a string in J...
Get substring from the end with string subs...
Get substring with String slice() method in...
Get the character in the given position for...
Get the character's character code at the g...
Get the length of a string in JavaScript
Get the number of characters in the string ...
Match string using regular expressions in J...
Parse string in scientific to number in Jav...
Repalce a string with regular expression in...
Replace a substring with String in JavaScri...
Replace string with a custom function in Ja...
...