hasOwnProperty.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 write(v) { WScript.Echo(v + ""); }
  6. var o = new Object();
  7. var a = [11,12,13];
  8. a[o] = 100;
  9. a.x = 200;
  10. o.x = 300;
  11. a.some = undefined;
  12. write("------------ hasOwnProperty ------------");
  13. write(o.hasOwnProperty("x"));
  14. write(o.hasOwnProperty("y"));
  15. write(o.hasOwnProperty(""));
  16. write(o.hasOwnProperty());
  17. write(a.hasOwnProperty(0));
  18. write(a.hasOwnProperty(1));
  19. write(a.hasOwnProperty(2));
  20. write(a.hasOwnProperty(3));
  21. write(a.hasOwnProperty("0"));
  22. write(a.hasOwnProperty("1"));
  23. write(a.hasOwnProperty("2"));
  24. write(a.hasOwnProperty("3"));
  25. write(a.hasOwnProperty("x"));
  26. write(a.hasOwnProperty("some"));
  27. write(a.hasOwnProperty("y"));
  28. write(a.hasOwnProperty(""));
  29. write(a.hasOwnProperty("length"));
  30. write(a.hasOwnProperty());
  31. write(a.hasOwnProperty(o));
  32. write(a.hasOwnProperty("o"));
  33. write(a.hasOwnProperty("[object Object]"));