in

JAVASCRIPT STRINGS | Introduction To Strings Objects in JavaScript

In this tutorial we will be looking at the JavaScript strings which entails the string methods, string properties and HTML string wrappers. In our previous tutorial we discussed about JavaScript boolean and we discussed the properties and methods associated with the boolean object. If you haven’t gone through the tutorial you can do so using the link below

Read previous tutorial on: JAVASCRIPT BOOLEAN | Introduction to Boolean Object in JavaScript

JAVASCRIPT STRINGS OBJECT

JavaScript strings object helps to wrap the normal JavaScript strings with methods that can be useful. Recall that JavaScript can convert between the JavaScript strings primitives and the string objects and this is done automatically. We can also secure the help of a string object on any primitive JavaScript string.

SYNTAX FOR JAVASCRIPT STRING OBJECT

var strObj = new String(string value);

JAVASCRIPT STRINGS PROPERTIES

S/N PROPERTY DESCRIPTION
1 length This is used to return the string length
2 prototype This allows developers to add object properties and method
3 Constructor This is used to return the string function that was used to create the object

JAVASCRIPT STRINGS METHODS

Below shows a comprehensive list of string methods available to a string object

S/N METHOD NAME METHOD DESCRIPTION
1 indexOf() This is used to return the index or position of the first occurrence of a specified value present in a string
2 charAt() This is used to return the character found at the specified position
3 lastIndexOf() This is used to return the index of the last occurrence of a specified value found in the string
4 Concat() This is used to join the text of two strings and gives a single new string as result
5 match() This is used to match expressions with strings
6 localCompare() This is used to compare any two elements in javascript and returns a positive or negative number depending on the outcome of the comparison
7 replace() This is used to replace an expression with a string match
8 search() This is used to search for a match between an expression and a specified string
9 slice() This is used to extract a particular section of a string and return a new string
10 split() This is used to split string objects into array of strings
11 substring() This is use to return a part of a given string from the start index to the end index
12 valueOf() This is used to return the value of an object
13 toUpperCase() This is used to return a string value in uppercase format
14 toLowerCase() This is used to return a string value in lowercase format
15 toString() This is used to return a string for the object that was specified
16 toLocalUpperCase() This is used to return the character within a string as upper case while referencing the local
17 toLocalLowerCase() This is used to return the character within a string as lower case while referencing the local
18 substr() This is used to extract length character from a string while counting from the start index.
19 charCodeAt() This returns a number that represents the Unicode value of the character

STRING HTML WRAPPERS

well wrapped in an HTML tag

S/N STRING METHOD NAME STRING METHOD DESCRIPTION
1 big() This is used to create a string that displays in a big font
2 fontcolor() This is used to display strings in a specified color
3 fixed() This is used to display strings in a fixed font
4 blink() This is used to make strings blink
5 anchor() This is used to create an HTML anchor
6 italics() This is used to display strings in italics
7 sup() This  is used to display strings in superscript
8 sub() This  is used to display strings in subscript
9 small() This is used to display strings in a small font
10 strike() This  is used to display strings in strikeout format
11 link() This is used to create an HTML hypertext link for a url
12 bold() This is used to display strings in a bold font
13 fontsize() This is used to display strings in a specified font size

NEXT TUTORIAL : JAVASCRIPT – ARRAYS

What do you think?

website traffic

How i Increased My Website Traffic in One Month Using Backlinks

javascript array

JAVASCRIPT ARRAY | Introduction to Array Objects In JavaScript