Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Wednesday, 24 June 2015

String in Javascript:

The javascript string is an object which represents sequence of character.

We can create string in javascript in two ways:

1.      Using String Literal
2.      Using String object

1.      Using String literal: syntax to create string using string literal:
Var newstr= “This is string”;

Example:
<script>
        var newstr = "this is new string";
        document.write(newstr);
    </script>

2.     Using String Object:

Syntax to create new string using string object as given below:

Var newstr= new String(“new string”);

Example:
    <script>
        var newstr = new String("this is new string");
        document.write(newstr);

    </script>
Categories: ,

0 comments:

Post a Comment