前端学习案例-object.keys和Object.getOwnPropertyNames

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>funciton</title>
</head>
<body>
    <script>
        var obj={
            a:1,
            b:2,
            c:3
        }
        Object.defineProperty(obj,"b",{
            enumerable:false
        })
        // 忽略运算符enumerable:false
        console.log(Object.leys(obj))//["a","c"]
        console.log(Object.getOwnPropertyNames(obj))//["a","b","c"]
    </script>
</body>
</html>

posted @ 2022-08-20 21:55  前端导师歌谣  阅读(14)  评论(0)    收藏  举报