Skip to Main Content
JavaScript: The Definitive Guide, Fourth Edition
book

JavaScript: The Definitive Guide, Fourth Edition

by David Flanagan
November 2001
Intermediate to advanced content levelIntermediate to advanced
936 pages
68h 43m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, Fourth Edition

Name

String — support for strings

Availability

JavaScript 1.0; JScript 1.0; ECMAScript v1

Inherits from/Overrides

Inherits from Object

Constructor

new String(s) // Constructor function
String(s) // Conversion function

Arguments

s

The value to be stored in a String object or converted to a primitive string.

Returns

When String( ) is used as a constructor with the new operator, it returns a String object, which holds the string s or the string representation of s. When the String( ) constructor is used without the new operator, it simply converts s to a primitive string and returns the converted value.

Properties

length

The number of characters in the string.

Methods

charAt( )

Extracts the character at a given position from a string.

charCodeAt( )

Returns the encoding of the character at a given position in a string.

concat( )

Concatenates one or more values to a string.

indexOf( )

Searches the string for a character or substring.

lastIndexOf( )

Searches the string backward for a character or substring.

match( )

Performs pattern matching with a regular expression.

replace( )

Performs a search-and-replace operation with a regular expression.

search( )

Searches a string for a substring that matches a regular expression.

slice( )

Returns a slice or substring of a string.

split( )

Splits a string into an array of strings, breaking at a specified delimiter string or regular expression.

substring( )

Extracts a substring of a string.

substr( )

Extracts a substring of a string. A variant of substring( ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

John Pollock
Coding with JavaScript For Dummies

Coding with JavaScript For Dummies

Chris Minnick, Eva Holland

Publisher Resources

ISBN: 0596000480Supplemental ContentCatalog PageErrata