<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>indexOf用法</title>
</head>
<body>
<script type="text/javascript">
var str = "ABCDEFGHIJKA"
document.write(str.indexOf("A") + "<br />")
document.write(str.indexOf("D") + "<br />")
document.write(str.indexOf("d"))
</script>
</body>
</html>
indexOf返回字符串首次出现的位置,并区分大小写
输出:0 3 -1