String properties and methods

by Brian von Konsky

JavaScript

// Sample string
var str="This quick brown fox jumped over the fence";

// Useful String Property
var len = str.length; // get length of string

// Useful String Methods
var p1 = str.indexOf("quick"), // find position of quick
    s1 = str.slice(6, 10),     // slice from position 6 to 10
    s2 = str.replace("quick", "slow"), // Change adjective
    a1 = str.split(" "); // convert to array

console.log("Use debugger to see values");