Blogger Information
Blog 40
fans 0
comment 0
visits 29308
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
作业--2019-05-07
小人物的博客
Original
685 people have browsed it

<!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>

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post