NumericPropertyIsEnumerable.js 1.0 KB

123456789101112131415161718192021222324
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function verify(act,exp,msg)
  6. {
  7. if(act!=exp)
  8. WScript.Echo(act + " " + msg);
  9. else
  10. WScript.Echo("pass");
  11. };
  12. var myobj = { a: "apple", 101: 1 }
  13. verify (myobj.propertyIsEnumerable('a'), true, "property should be enumerable");
  14. verify (myobj.propertyIsEnumerable(101), true, "numeric property should be enumerable");
  15. verify (myobj.propertyIsEnumerable("101"), true, "numeric property should be enumerable");
  16. verify (myobj.propertyIsEnumerable("10"), false, "non-existent numeric property should not be enumerable");
  17. for (o in myobj)
  18. {
  19. verify (myobj.propertyIsEnumerable(o), true, "for...in loop propertyIsEnumerable enum testing");
  20. }