es5array_replaceprotoarr.js 673 B

123456789101112131415161718192021
  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 test(o)
  6. {
  7. o[0] = 1;
  8. }
  9. var arr = [];
  10. function Ctor() { this[1] = 2; };
  11. Object.defineProperty(arr, "0", { value: 0, writable: false });
  12. var o = new Ctor();
  13. o.__proto__ = arr;
  14. test(o);
  15. WScript.Echo(o[0]);
  16. var o = new Ctor();
  17. o.__proto__ = arr;
  18. test(o);
  19. WScript.Echo(o[0]);