-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindexOf.html
More file actions
48 lines (36 loc) · 955 Bytes
/
indexOf.html
File metadata and controls
48 lines (36 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="indexOf()方法返回给定元素能找在数组中找到的第一个索引值,否则返回-1。">
<meta name="link" content="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf" />
<title>indexOf</title>
</head>
<body>
<h1>Array</h1>
<code>
// array
<br />
var array = [2, 4, 6, 8, 10];
<br />
array.indexOf(2); //0
</code>
<h1>String</h1>
<code>
var string = "Hello World!"
<br />
console.log(string.indexOf('l')); //2
</code>
<script type="text/javascript">
// array
var array = [2, 4, 6, 8, 10];
array.indexOf(2); //0
//String
var string = "Hello World!"
console.log(string.indexOf('l')); //2
</script>
</body>
</html>