获得对象属性特征

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sss</title>
</head>
<body>
    
    <script type="text/javascript">
        
        let user = {
            name:"angdh",
            age:11
        };

        console.log(
            JSON.stringify(Object.getOwnPropertyDescriptors(user),null,2)
            );
        /*

            {
              "name": {
                "value": "angdh",
                "writable": true,
                "enumerable": true,
                "configurable": true
              },
              "age": {
                "value": 11,
                "writable": true,
                "enumerable": true,
                "configurable": true
              }
            }
        */
    </script>

</body>
</html>

 

上一篇:对象的属性定义


下一篇:Writable接口与序列化机制