ObjLitInitFld.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. var obj = {1:1, foo:1};
  6. Output(obj);
  7. Object.defineProperty(Object.prototype, '1', { value:"ProtoFoo", writable:false, configurable:true, enumerable:true });
  8. Object.defineProperty(Object.prototype, 'foo', { value:"ProtoFoo", writable:false, configurable:true, enumerable:true });
  9. var obj = {1:1, foo:1};
  10. Output(obj);
  11. delete Object.prototype[1];
  12. delete Object.prototype.foo;
  13. Object.defineProperty(Object.prototype, '1', {
  14. get: function() { WScript.Echo("GETTER"); },
  15. set: function(v) { WScript.Echo("SETTER"); },
  16. configurable:true, enumerable:true });
  17. Object.defineProperty(Object.prototype, 'foo', {
  18. get: function() { WScript.Echo("GETTER"); },
  19. set: function(v) { WScript.Echo("SETTER"); },
  20. configurable:true, enumerable:true });
  21. var obj = {1:1, foo:1};
  22. Output(obj);
  23. function Output(o)
  24. {
  25. for (var i in o)
  26. {
  27. WScript.Echo(i + ": '" + o[i] + "'");
  28. }
  29. }