救救孩子吧
写四个按钮,分别是创建(空数组) ,添加(添加一个人) ,修改(修改人的各个属性),删除数组功能。数组元素里面是对象,对象是{name:xx,sex:xx,age:xx}
写四个按钮,分别是创建(空数组) ,添加(添加一个人) ,修改(修改人的各个属性),删除数组功能。数组元素里面是对象,对象是{name:xx,sex:xx,age:xx}
2020-07-06
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="button" value="创建空数组" onclick="cre()"/>
<input type="button" value="添加对象" onclick="ins()"/>
<input type="button" value="修改数组" onclick="cha()"/>
<input type="button" value="删除数组" onclick="del()"/>
<script type="text/javascript">
function cre(){
var a=new Array();
console.log(a);
}
function ins(){
a={name:"xx",sex:"xx",age:"xx"};
console.log(a);
}
function cha(){
a.name="是这样吗?"
console.log(a);
}
function del(){
delete a;
console.log(a);
}
</script>
</body>
</html>
举报