增加(C)
方式一
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let person = new Person();
person.name = "BNTang";
person.say = function () {
console.log("hello world");
}
console.log(person);
</script>
</head>
<body>
</body>
</html>
方式二
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let person = new Person();
person["name"] = "zs";
person["say"] = function () {
console.log("hello world");
}
console.log(person);
</script>
</head>
<body>
</body>
</html>
删除(R)
方式一
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let p = new Person();
delete p.name;
delete p.say;
console.log(p);
</script>
</head>
<body>
</body>
</html>
方式二
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let p = new Person();
delete p["name"];
delete p["say"];
console.log(p);
</script>
</head>
<body>
</body>
</html>
修改(U)
方式一
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let p = new Person();
p.name = "BNTang";
p.say = function () {
console.log("hi");
}
p.say();
console.log(p);
</script>
</head>
<body>
</body>
</html>
方式二
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let p = new Person();
p["name"] = "ww";
p["say"] = function () {
console.log("hi");
}
p.say();
console.log(p);
</script>
</head>
<body>
</body>
</html>
查询(D)
方式一
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let p = new Person();
p.name = "BNTang";
p.say = function () {
console.log("hi");
}
console.log(p.name);
</script>
</head>
<body>
</body>
</html>
方式二
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script>
class Person {
}
let p = new Person();
p.name = "BNTang";
p.say = function () {
console.log("hi");
}
console.log(p["name"]);
</script>
</head>
<body>
</body>
</html>