其他分享
首页 > 其他分享> > 获得对象属性特征

获得对象属性特征

作者:互联网

 

<!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>

 

标签:angdh,对象,enumerable,configurable,writable,特征,user,true,属性
来源: https://www.cnblogs.com/angdh/p/14828622.html