php-mysql tutorial

Designed By NISHANT GUPTA

  • Home
  • PHP
  • HTML
  • CSS
  • JavaScript
  • JQuery
  • Contact-us
  • Learn HTML

    • Introduction of HTML
    • Image Handling in HTML
    • List Handling in HTML
    • Font Handling in HTML
    • Table Handling in HTML
    • Form Handling in HTML
  • Learn CSS

    • Introduction of CSS
    • Styling Background in CSS
    • Styling Text in CSS
    • Styling Font in CSS
    • Styling Link in CSS
    • Styling List in CSS
    • Styling Table in CSS
    • Styling Div in CSS
    • Styling Span in CSS
    • Positioning in CSS
    • Display in CSS
  • Learn JavaScript

    • Introduction of JavaScript
    • Data Type in JavaScript
    • Variable in JavaScript
    • Oprator in JavaScript
    • Cond. Statement in JavaScript
    • Loop in JavaScript
    • Array in JavaScript
    • Function in JavaScript
    • Date in JavaScript
    • String in JavaScript
    • DOM in JavaScript
    • Event Handling in JavaScript
    • Form Handling in JavaScript
  • Learn PHP-MYSQL

    • Introduction of PHP
    • Decision Control in PHP
    • Loop in PHP
    • Array in PHP
    • Function in PHP
    • Form Handling in PHP
    • File Inclusion in PHP

String in JavaScript

The String Object

JavaScript String object allows us to store a sequence of characters.

It can be created using :

  1. String Literal

    var city=“Bhopal”;

  2. String Constructor

    var city=new String(“Bhopal”);

Using String Methods/Propertiess

length: Returns the length of the string

Example

var str=“Bhopal”

alert(str.length();

//Output:

6

charAt(index): Returns the character at the given

Example

var str=“Bhopal”

alert(str.charAt(4));

//Output:

a

charCodeAt(index):Returns the unicode(ascii) of the character at specified index

Example

var str=“Bhopal”

alert(str.charCodeAt(4));

//Output:

97

indexOf(text):Returns the index of given text in the calling string.

Example

var str=“Programming”

alert(str.indexOf (“ram”));

//Output:

4

lastIndexOf(text): Returns the last index of given text in the calling string.

Example

var str=“Welcome User”

alert(str.indexOf (“e”));

//Output:

10

replace(string,string):

 

Replaces first occurrence of given string with new string.

 

Example

var s1=“Welcome User”

var s2=s1.replace(“User”,”Nishant”);

alert(s2);

//Output:

Welcome Nishant

substr(start,lenght):

  Returns length number of characters from start position.

Example

var s1=“Programming”

var s2=s1.substr(3,4);

alert(s2);

//Output:

gram 

Advertisements

 

©  2014 All Rights Reserved  •  Design by >Nishant Gupta.

Privacy Policy • Terms of Use