Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var colors = ['yellow','blue','red','pink'];
//刪除第三筆陣列元素,僅刪除一筆
colors.splice(2,1);
console.log(colors);
//indexOf 詢問第一筆相符資料的索引
console.log(colors.indexOf('pink'));
// splice 用法
colors.splice(colors.indexOf('red'));
console.log(colors);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers