Javascript string browser compatibility problem analysis

  • 2020-03-30 04:28:47
  • OfStack

This article analyzes the compatibility problem of Javascript string browser by example. Share with you for your reference. Specific analysis is as follows:

So let's look at the incompatibility, if I want to get the position of a string

var str='aavvvcc';
console.info(str[0]);

This type of writing is not compatible with Internet explorer 7 or any other browser
var str='aavvvcc';
console.info(str.charAt(1));

With charAt(), you can get a character in a string and be compatible with all of them.


Related articles: