<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>0507作业</title>
</head>
<body>
<script>
// 1. 使用forEach()遍历数组
// 2. 通过查手册编写splice()方法的案例,实现数组元素的添加, 删除和更新操作
document.write('创建数组</br>');
var books = ['Html','css','JavaScript','PHP','MYSQL'];
books.forEach(function (value,key) {
document.write(key + '--' +value +'</br>');
});
document.write('</br>');
//document.write(books + "<br />")
document.write('删除第3个元素</br>');
books.splice(2,1);
books.forEach(function (value,key) {
document.write(key + '--' +value +'</br>');
});
document.write('</br>');
document.write('插入java到第2个元素位置,</br>');
books.splice(1,0,"java")
books.forEach(function (value,key) {
document.write(key + '--' +value +'</br>');
});
document.write('</br>');
document.write('将第五个mysql改为sql,</br>');
books.splice(4,1,"SQL")
books.forEach(function (value,key) {
document.write(key + '--' +value +'</br>');
});
</script>
</body>
</html>