当前位置:网站首页>6. Data agent object Defineproperty method
6. Data agent object Defineproperty method
2022-07-03 19:39:00 【Shura MIUI】
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
<script>
var number = 10;
//1
let person = {
name: ' Zhang San ',
sex: ' male '
};
// Defining attributes ,
Object.defineProperty(person, 'age', {
// value: 18,
enumerable: false, // When enumerable by false when age Properties cannot be enumerated ,
// writable:false,//false The attribute value cannot be modified
// configurable: false, //false Attributes cannot be deleted and defined set Method
// When accessing age Called when value get Method , When defining get When the method is used ,value and writable Don't define
// get: function() {
// return number;
// },
// When modifying age Execute when value set Method , When defining set When the method is used ,value、writable、configurable Not definable
set: function(value) {
console.log(' Someone modified it age attribute , value =>'+value);
number = value;// Yes age When modifying, assign a value to number
}
});
console.log(Object.keys(person));
// 0: "name"
// 1: "sex"
// length: 2
for (let key in person) console.log(person[key]);
// Zhang San
// male
//2
// The following age Attributes can be enumerated
person = {
name: ' Zhang San ',
sex: ' male ',
age: 18
};
console.log(Object.keys(person));
// 0: "name"
// 1: "sex"
// 2: "age"
for (let key in person) console.log(person[key]);
// Zhang San
// male
// 18
</script>
边栏推荐
- 03 -- QT OpenGL EBO draw triangle
- 04 -- QT OpenGL two sets of shaders draw two triangles
- FBI warning: some people use AI to disguise themselves as others for remote interview
- TFs and SVN [closed] - TFs vs SVN [closed]
- Cross compile opencv with contrib
- I study database at station B (4): DQL
- 第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
- 05 -- QT OpenGL draw cube uniform
- Chapter 2: 4-digit Kaplan number, search even digit Kaplan number, search n-digit 2-segment sum square number, m-digit ingenious square number without 0, specify the number to form a 7-digit square nu
- 第一章:求n的阶乘n!
猜你喜欢
2022 - 06 - 30 networker Advanced (XIV) Routing Policy Matching Tool [ACL, IP prefix list] and policy tool [Filter Policy]
第一章:递归求n的阶乘n!
Basic principle of LSM tree
Counting from the East and counting from the West will stimulate 100 billion industries. Only storage manufacturers who dare to bite the "hard bone" will have more opportunities
第一章:三位阶乘和数,图形点扫描
Using the visualization results, click to appear the corresponding sentence
Ae/pr/fcpx super visual effects plug-in package fxfactory
04 -- QT OpenGL two sets of shaders draw two triangles
2022-06-30 advanced network engineering (XIV) routing strategy - matching tools [ACL, IP prefix list], policy tools [filter policy]
[proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
随机推荐
[free sharing] kotalog diary2022 plan electronic manual ledger
Utilisation de base du cadre unitest
OSPF - detailed explanation of stub area and full stub area
Zhang Fei hardware 90 day learning notes - personal record of day 3, please see my personal profile / homepage for the complete
第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
Strict data sheet of new features of SQLite 3.37.0
Chapter 2: find the classical solution of the maximum Convention and the least common multiple of a and B, find the conventional solution of the maximum Convention and the least common multiple of a a
5- (4-nitrophenyl) - 10,15,20-triphenylporphyrin ntpph2/ntppzn/ntppmn/ntppfe/ntppni/ntppcu/ntppcd/ntppco and other metal complexes
SQL injection for Web Security (1)
Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
I study database at station B (4): DQL
Basic principle of LSM tree
[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]
CMD implements the language conversion of locale non Unicode programs
第一章:求n的阶乘n!
[water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]
Common text labels
Use unique_ PTR forward declaration? [repetition] - forward declaration with unique_ ptr? [duplicate]
Rd file name conflict when extending a S4 method of some other package
Free hand account sharing in September - [cream Nebula]