js get index of last element in string code example Example: get last char javascript var lastChar = myString[myString.length -1];