Some of the characters in normal operation javascript

1. Get the first character

var str = "hello word";
console.log(str[0]);   // h

 

2, access to the last character

var str = "hello word";
console.log(str[str.length - 1]);   // d

 

Guess you like

Origin www.cnblogs.com/xulinjun/p/11573073.html