您当前的位置: 首页 > 

暂无认证

  • 2浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

详解对象增删改查

发布时间:2020-09-11 22:20:30 ,浏览量:2

<!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> <script type="text/javascript"> class Person{} let p=new Person(); //增加 p.name="cyg"; //p["name"]="liwen"; p.say=function() { console.log("cyg"); } /*p["say"]=function()
		{
			console.log("liwen1");
		}*/ console.log(p); </script> </body> </html> 

在这里插入图片描述

删除:

<!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> <script type="text/javascript"> class Person{} let p = new Person(); p["name"] = "zs"; p["say"] = function(){ console.log("hello world"); } //删除 delete p["say"]; console.log(p); </script> </body> 

在这里插入图片描述

修改;

<!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> <script type="text/javascript"> class Person{} let p = new Person(); p["name"] = "zs"; p["say"] = function(){ console.log("hello world"); } //修改: p["name"]="liwen"; p["say"]=function() { console.log("liwen1"); } console.log(p); </script> </body> </html> 

在这里插入图片描述

查询:

<!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> <script type="text/javascript"> class Person{} let p = new Person(); p["name"] = "zs"; p["say"] = function(){ console.log("hello world"); } //查询 console.log(p["name"]); console.log(p["say"]); </script> </body> </html> 

在这里插入图片描述

关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.0821s