API Docs for: 1.0.0
Show:

String Class

Defined in: default.js:134
Module: Intro2JavaScript

Extensions to the String class.

Constructor

String

()

Defined in default.js:134

Methods

decodeUtf8

() String

Defined in default.js:139

Decodes string from UTF-8 to ASCII format.

Returns:

encodeUtf8

() String

Defined in default.js:172

Encodes string from ASCII to UTF-8 format.

Returns:

repeat

(
  • n
)
String

Defined in default.js:201

Returns the string repeated n times.

var s = "~-";
console.log(s.repeat(10));
// ~-~-~-~-~-~-~-~-~-~-

Parameters:

  • n Int

Returns:

String: If n is NaN then return the string else return repeated string.

replaceChars

(
  • tar
  • rep
)
String

Defined in default.js:222

Replaces all target characters with the replacement character. Works by splitting it into an array and then rejoining it.

var s = "Intro to Javascript";
console.log(s.replaceChars(" ", "_"));
// Intro_to_Javascript

Parameters:

  • tar String

    target character to replace

  • rep String

    replacement character

Returns:

String: with target characters replaced

reverse

() String

Defined in default.js:239

Reverses the characters in a string.

var s = "Intro to Javascript";
console.log(s.reverse());
// tpircSavaJ ot ortnI

Returns:

stripSpaces

() String

Defined in default.js:253

Strips spaces from a string.

Returns:

trim

() String

Defined in default.js:280

Trims leading and trailing whitespace from a string.

Returns:

trimLeft

() String

Defined in default.js:262

Trims leading whitespace from a string.

Returns:

trimRight

() String

Defined in default.js:271

Trims trailing whitespace from a string.

Returns:

ungetc

() String

Defined in default.js:289

Removes the last char from a string.

Returns: