코드:
결과보기 »
<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <title>JavaScript Object Method</title> </head> <body> <h1>객체의 propertyIsEnumerable() 메소드</h1> <script> function Dog(color, name, age) { this.color = color; this.name = name; this.age = age; } var myDog = new Dog("흰색", "마루", 1); // color 프로퍼티의 enumerable 속성을 false로 설정함. Object.defineProperty(myDog, 'color', { enumerable : false} ); document.write(myDog.propertyIsEnumerable("color") + "<br>"); // false document.write(myDog.propertyIsEnumerable("name") + "<br>"); // true document.write(myDog.propertyIsEnumerable("age")); // true </script> </body> </html>