String object in JavaScript

The String object helps you work with a series of characters; It helps handle the original string data types in JavaScript with some help methods.

When JavaScript automatically changes between the original string and String objects, you can call any help method of the String object on an original string.

Syntax

Use the following syntax to create a String object:

 var val = new String ( string ); 

The string parameter is a sequence of characters that has been correctly encoded.

Properties of String

Below is a list of properties of the String object and its description.

Properties Description

constructor

Returns a reference to the String function that creates that object

length

Returns the length of the string

prototype

The prototype property allows you to add properties and methods to an object.

Methods of String

Below is a list of available methods in the String object with its description.

Method Description

charAt ()

Returns the character at the index (index) specified

charCodeAt ()

Returns a number indicating the Unicode value of the character in the given index

concat ()

match the text of the two strings and return a new string

indexOf ()

Returns the index in the String object calling the first occurrence of the specified value, or -1 if not found

lastIndexOf ()

Returns the index in the String object calling of the last occurrence of the specified value, or -1 if not found

localeCompare ()

Returns an indication whether or not a string refers to before or after, or is the same as the given string in the sort order

match ()

Used to match a Regular Expression with a string

replace ()

Used to find a match between a given Regular Expression and a string, and to replace a substring that matches a new substring.

search ()

Execute the search for a match between a regular expression and a specified string

slice ()

Extract an area of ​​a string and return a new string

split ()

Divide a String object into an array of strings by dividing the string into sub-strings

substr ()

Returns the characters in a string starting at the specified position with a specified number of characters

substring ()

Returns characters in a string between two indexes within the string

toLocaleLowerCase ()

The characters inside a string are converted into lowercase while respecting the current Locale

toLocaleUpperCase ()

The characters inside a string are transformed into floral typefaces while respecting the current Locale

toLowerCase ()

Returns the value of the calling string being converted to lower case

toString ()

Returns a string representing the specified object

toUpperCase ()

Returns the value of the calling string being converted to uppercase

valueOf ()

Returns the original value of the specified object

String HTML Wrappers

Below is a list of methods that return a copy of the string wrapped within an appropriate HTML tag.

Method Description

anchor ()

Create an Anchor HTML that is used as a hypertext target (hypertext target)

big ()

Create a string to be displayed in a big font as if it were in a tag

blink ()

Create a flashing sequence as if it were in a card

bold ()

Create a string to be displayed in bold form as if it were in a tag

fixed ()

Create a string to be displayed in a fixed font as if it were in a tag

fontcolor ()

Create a string to be displayed in a fixed color as if it were in a tag

fontsize ()

Making a string is displayed in a font size defined as when it is in a tag

italics ()

Make a string in italic format as if it were in a card

link ()

Create an HTML hypertext link that requires another URL

small ()

Make a string displayed in Small font format as if it were in a tag

strike ()

Make a string displayed in the form of dashed text as if it were in a tag

sub ()

Make a string displayed in the form of the lower index as if it were in a tag

sup ()

Make a string displayed in the form of the upper index as if it were in a tag

According to Tutorialspoint

Previous article: Boolean object in JavaScript

Next post: Array (Array) in JavaScript

4 ★ | 1 Vote

May be interested

  • Object Number in JavaScriptObject Number in JavaScript
    the number object represents the date in the form of a numeric value, or an integer or floating-point number. generally, you don't need to worry about number objects because the browser automatically converts number literals to illustrate the number classes.
  • Basic about jQueryBasic about jQuery
    this article will explain the basic concepts commonly used in jquery such as: string (string), number (number), boolean, array (array), function, parameter, context, ...
  • Syntax of JavaScriptSyntax of JavaScript
    javascript can be implemented using javascript commands that are placed in html tags ... in a web page.
  • String (String) in PHPString (String) in PHP
    string is a sequence of characters, you will find available string handling functions in php at php string (string) handler
  • String (String) in C / C ++String (String) in C / C ++
    this form of string originates from c language and continues to be supported in c / c ++. the string in the c programming language is essentially a one-dimensional array of characters that ends with a null character ''.
  • Print pages in JavaScriptPrint pages in JavaScript
    many times you will love to put a button on your website to print the content of that page through a printer. javascript helps you perform this function by using the print function of the window object.
  • How to turn on and turn off Javascript on Firefox, ChromeHow to turn on and turn off Javascript on Firefox, Chrome
    javascript is an object-based scripting language that often creates eye-catching effects on websites.however, if you need to turn on or off javascript, the following article will guide you to do that.
  • string.h in Cstring.h in C
    the file header named string.h in c library defines a variable type, a macro and various functions to manipulate character arrays.
  • Regular Expression and RegExp in JavaScriptRegular Expression and RegExp in JavaScript
    a regular expression is an object that describes a pattern of characters.
  • Array (Array) in JavaScriptArray (Array) in JavaScript
    array object - array helps you store multiple values ​​in a single variable. it stores a set of fixed-size ranges of elements in the same type (type). an array is used to store a data set, but it is often more useful to think of an array as a collection of variables in the same type.