Home » String Methods List using JavaScript Example

String Methods List using JavaScript Example

String Methods List using JavaScript Example

Here is a All the list of each method and its Example.

DataType(String) HTML Wrapper javascript methods

  • anchor() Creates an anchor
  • big() HTML Dom Show a DataType(String) using a big font
  • blink() HTML Dom Show a blinking DataType(String)
  • bold() HTML Dom Show a DataType(String) in bold
  • fixed() HTML Dom Show a DataType(String) using a fixed-pitch font
  • fontcolor() HTML Dom Show a DataType(String) using a specified color
  • fontsize() HTML Dom Show a DataType(String) using a specified size
  • italics() HTML Dom Show a DataType(String) in italic
  • link() HTML Dom Show a DataType(String) as a hyperlink
  • small() HTML Dom Show a DataType(String) using a small font
  • strike() HTML Dom Show a DataType(String) with a strikethrough
  • sub() HTML Dom Show a DataType(String) as subscript datastring
  • sup() HTML Dom Show a DataType(String) as superscript datastring
Read Also:  JQuery Remove combobox items(options) from DropDownList

DataType(String) Length

The length Simple property returns the length of a DataType(String):

var txtdata = "Welcome to Pakainfo.com";
var sln = txtdata.length; 

Searching a DataType(String) in a DataType(String)

var myLiveDataType = "Please locate where 'locate' occurs!";
var result = myLiveDataType.indexOf("locate");

lastIndexOf()

var myLiveDataType = "Please locate where 'locate' occurs!";
var result = myLiveDataType.lastIndexOf("locate");

var myLiveDataType = "Please locate where 'locate' occurs!";
var result = myLiveDataType.indexOf("locate",15);

Searching for a DataType(String) in a DataType(String)

var myLiveDataType = "Please locate where 'locate' occurs!";
var result = myLiveDataType.search("locate")

The slice() javascript method

var myLiveDataType = "web, host, pendrive";
var res = myLiveDataType.slice(7, 13);

var myLiveDataType = "web, host, pendrive";
var res = myLiveDataType.slice(-12, -6);
var res = myLiveDataType.slice(7); 
var res = myLiveDataType.slice(-12); 

The subDataType(String)() javascript method

var myLiveDataType = "web, host, pendrive";
var res = myLiveDataType.subDataType(String)(7, 13);

The substr() javascript method

var myLiveDataType = "web, host, pendrive";
var res = myLiveDataType.substr(7, 6);

Replacing DataType(String) Content

myLiveString = "Please visit Live24u!";
var n = myLiveDataType.replace("Live24u", "W3Schools");

myLiveString = "Please visit Live24u and Live24u!";
var n = myLiveDataType.replace("Live24u", "W3Schools");

myLiveString = "Please visit Live24u and Live24u!";
var n = myLiveDataType.replace(/Live24u/g, "W3Schools");

myLiveString = "Please visit Live24u!";
var n = myLiveDataType.replace("Live24u", "W3Schools");

myLiveString = "Please visit Live24u!";
var n = myLiveDataType.replace(/Live24u/i, "W3Schools");

Converting to Upper and Lower Case

var datastring1 = "welcome - Pakainfo.com";       // DataType(String)
var datastring2 = datastring1.toUpperCase();  // datastring2 is datastring1 converted to upper

var datastring1 = "welcome - Pakainfo.com";       // DataType(String)
var datastring2 = datastring1.toLowerCase();  // datastring2 is datastring1 converted to lower 

The concat() javascript method

var datastring1 = "live24u";
var datastring2 = "com";
var datastring3 = datastring1.concat(" ", datastring2);

var datastring = "live24u" + " " + "com!";
var datastring = "live24u".concat(" ", "com!"); 

Extracting DataType(String) Characters

The charAt() javascript method

character at the specified index.

Read Also:  Pop Push Shift Unshift Array Methods

var myLiveDataType = "welcome - Pakainfo.com";
myLiveDataType.charAt(0);            

The charCodeAt() javascript method

var myLiveDataType = "welcome - Pakainfo.com";
myLiveDataType.charCodeAt(0);         

Accessing a DataType(String) as an Array is Unsafe

var myLiveDataType = "welcome - Pakainfo.com";

myLiveDataType[0];     

indexOf

var myLiveDataType = "foo",
    substring = "oo";
myLiveDataType.indexOf(substring) !== -1;

Converting a DataType(String) to an Array

var myLiveDataType = "a,b,c,d,e";   // DataType(String)
myLiveDataType.split(",");          // Split on commas
myLiveDataType.split(" ");          // Split on spaces
myLiveDataType.split("|");

var myLiveDataType = "live24u";       // DataType(String)
myLiveDataType.split("");


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel 6 Set Timestamps using Eloquent Model
  2. Read Also:  Bootstrap datepicker Disable Dates Dynamically in jQuery
  3. Read Also:  PHP Toggle Like Dislike Rating System using jQuery Ajax
  4. Read Also:  JavaScript jQuery Tips and Tricks for Programmers
  5. Read Also:  Integration with Pagination Without WordPress Plugins
  6. Read Also:  Jquery Get Number of Characters String length
  7. Read Also:  jQuery Find Nested Parent Child Elements HTML DOM
  8. Read Also:  HTML Textbox CSS style examples
  9. Read Also:  Ajax Shopping Cart PHP MYSQLi Tutorial With Example
  10. Read Also:  WordPress Plugin Redirect After Activation

Leave a Comment

Your email address will not be published. Required fields are marked *