Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • String in JavaScript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 116
    Comment on it

    strings in JavaScript : Like other languages JavaScript also supports the string objects. String object is kind of collection of characters. We can store single character or sequence of characters in the String object.

    Example of defining strings in Javascript :

    var str1 = "This is String One";
    var str2 = 'Two';
    var msg = "His name is 'John'";
    var name = new String("Johnny");
    

    As you can see above there are different ways to defining the string in JavaScript, we can define string inside double quotes (test), single quotes('test'), or we can have single quotes inside the double quotes and also we can define the string object using String class.

    String Properties : String object has following properties :

    1. length : to return the length of the string.
    2. prototype : this property used to add the new property and methods in string object.

    String Methods : There are different methods which is supported by the all string objecs. Following are the list of the string methods :

    1. charAt() : Return the string at particular index;
    2. concat() : Join the strings and return new one.
    3. indexOf() : Return the index of the particular character.
    4. lastIndexOf() : Return the index of the particular character from it's last occurence.
    5. match() : matches the string against given regular expression and return the array of that string.
    6. replace() : It will first search the given string and then replace it's first occurence with other given string.
    7. search() : Will search the given string and return the index of that string.
    8. slice() : It is used to return the substring having start and end index.
    9. split() : It breaks the string for a given expression and return the array of substring.
    10. substr() : It is used to return the substring having start and end index.
    11. substring() : It is used to return the substring having start and end index.
    12. toString() : Convert and return the value into string object.
    13. toLowerCase() : Convert and return the string in lowercase letter.
    14. toUpperCase() : Convert and return the string in uppercase letter.
    15. trim() : It removes the whitespace from start and end position.
    16. valueOf() :
    17. charCodeAt() : Return the unicode value of specified index character.
    18. FromCharCode() : Return the character for specified unicode value.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: