String substring methods

my string
length property
substring, start at 3, stop before 6
slice, start at -5, stop before -3
a string
concatenate a string, " ", and my string
my string is unchanged
a string is unchanged

A copy of the JavaScript functions:

// sample-3-substring.js
// This sample shows String character methods

function display()
  {
  var output1 = document.getElementById("output1");
  var output2 = document.getElementById("output2");
  var output3 = document.getElementById("output3");
  var output4 = document.getElementById("output4");
  var output5 = document.getElementById("output5");
  var output6 = document.getElementById("output6");
  var output7 = document.getElementById("output7");
  var output8 = document.getElementById("output8");

  // String object
  my_string_object = new String("hippopotomas");
  a_string = new String("A");

  output1.value = my_string_object;
  output2.value = my_string_object.length;

  // substring includes the first character position,
  // to, but not including, the second character position
  // substring allows only positive numbers
  output3.value = my_string_object.substring(3, 6);
  // slice allows negative numbers, with -1 being
  // the last character.
  // Otherwise substring and slice are the same.
  output4.value = my_string_object.slice(-5, -3);

  output5.value = a_string;
  output6.value = a_string.concat(" ", my_string_object);
  output7.value = my_string_object;
  output8.value = a_string;
  }