es5array_protoarr.js 656 B

1234567891011121314151617181920
  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. Ctor.prototype = arr;
  12. Object.defineProperty(arr, "0", { value: 0, writable: false });
  13. var o = new Ctor();
  14. test(o);
  15. WScript.Echo(o[0]);
  16. var o = new Ctor();
  17. test(o);
  18. WScript.Echo(o[0]);