Home > Web Front-end > JS Tutorial > Analysis of Javascript string browser compatibility issues_javascript skills

Analysis of Javascript string browser compatibility issues_javascript skills

WBOY
Release: 2016-05-16 16:29:50
Original
1384 people have browsed it

This article analyzes Javascript string browser compatibility issues with examples. Share it with everyone for your reference. The specific analysis is as follows:

Let’s first look at the incompatible writing methods. If I want to get the number of a string

Copy code The code is as follows:
var str='aavvvcc';
console.info(str[0]);

This way of writing is not compatible with browsers below IE 7. The following provides a method that is fully compatible with browsers
Copy code The code is as follows:
var str='aavvvcc';
console.info(str.charAt(1));

Use charAt() to get a certain character in a string, and all are compatible.

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template