| 1 |
// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
// file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 |
|
| 5 |
js> var args = (function() { return arguments })() |
| 6 |
js> Object.getPrototypeOf(args) === Object.prototype |
| 7 |
true |
| 8 |
js> args.constructor === Object.prototype.constructor |
| 9 |
true |
| 10 |
js> Object.getOwnPropertyDescriptor(args, "constructor") === void 0 |
| 11 |
true |
| 12 |
js> args.toString() |
| 13 |
[object Arguments] |
| 14 |
|
| 15 |
js> var toStr = Object.prototype.toString; |
| 16 |
js> var _ = Object.prototype.toString = function() { |
| 17 |
> return this === args ? |
| 18 |
> "executes Object.prototype.toString.call(arguments)" : |
| 19 |
> "'this' should be 'arguments'" |
| 20 |
> } |
| 21 |
js> args.toString() |
| 22 |
executes Object.prototype.toString.call(arguments) |
| 23 |
js> Object.prototype.toString = toStr; undefined |
| 24 |
|
| 25 |
js> var toLocStr = Object.prototype.toLocaleString; |
| 26 |
js> var _ = Object.prototype.toLocaleString = function() { |
| 27 |
> return this === args ? |
| 28 |
> "executes Object.prototype.toLocaleString.call(arguments)" : |
| 29 |
> "'this' should be 'arguments'" |
| 30 |
> } |
| 31 |
js> args.toLocaleString() |
| 32 |
executes Object.prototype.toLocaleString.call(arguments) |
| 33 |
js> Object.prototype.toLocaleString = toLocStr; undefined; |
| 34 |
|
| 35 |
js> (function() { return arguments[2] })('a','b','c') |
| 36 |
c |
| 37 |
js> (function(x,y,z) { return arguments[2] })('a','b','c') |
| 38 |
c |
| 39 |
|
| 40 |
js> (function(x) { |
| 41 |
> arguments[0] = "modified"; |
| 42 |
> return x; |
| 43 |
> })("original") |
| 44 |
modified |
| 45 |
|
| 46 |
js> (function(x) { |
| 47 |
> x = "modified"; |
| 48 |
> return arguments[0]; |
| 49 |
> })("original") |
| 50 |
modified |
| 51 |
|
| 52 |
js> (function(x) { |
| 53 |
> delete arguments[0]; |
| 54 |
> arguments[0] = "modified"; |
| 55 |
> return x; |
| 56 |
> })("original") |
| 57 |
original |
| 58 |
|
| 59 |
js> (function(x) { |
| 60 |
> delete x; |
| 61 |
> var x = "modified"; |
| 62 |
> return arguments[0] |
| 63 |
> })("original") |
| 64 |
modified |
| 65 |
|
| 66 |
js> (function(x) { |
| 67 |
> Object.defineProperty(arguments, 0, {get:function(){return "modified"}}); |
| 68 |
> return arguments[0]; |
| 69 |
> })("original") |
| 70 |
modified |
| 71 |
|
| 72 |
js> (function(x) { |
| 73 |
> Object.defineProperty(arguments, 0, {get:function(){return "modified"}}); |
| 74 |
> return x; |
| 75 |
> })("original") |
| 76 |
original |
| 77 |
|
| 78 |
js> (function(x) { |
| 79 |
> Object.defineProperty(arguments, 0, {value:"modified"}); |
| 80 |
> return arguments[0]; |
| 81 |
> })("original") |
| 82 |
modified |
| 83 |
|
| 84 |
js> (function(x) { |
| 85 |
> Object.defineProperty(arguments, 0, {value:"modified"}); |
| 86 |
> return x; |
| 87 |
> })("original") |
| 88 |
modified |
| 89 |
|
| 90 |
js> (function() { for (var i in arguments) print(i); })('a','b','c') |
| 91 |
0 |
| 92 |
1 |
| 93 |
2 |
| 94 |
|
| 95 |
js> (function() { |
| 96 |
> arguments.a = 1; |
| 97 |
> Object.defineProperty(arguments, 'b', {value:2, enumerable:true}); |
| 98 |
> Object.defineProperty(arguments, 'c', {value:3, enumerable:false}); |
| 99 |
> Object.defineProperty(arguments, 0, {enumerable:false}); |
| 100 |
> for (var p in arguments) print(p); |
| 101 |
> })('hi') |
| 102 |
a |
| 103 |
b |
| 104 |
|
| 105 |
js> (function() { return Object.getOwnPropertyDescriptor(arguments, 0) === undefined })() |
| 106 |
true |
| 107 |
|
| 108 |
js> (function() { return Object.getOwnPropertyDescriptor(arguments, 0).toSource(); })("a") |
| 109 |
({value:"a", writable:true, enumerable:true, configurable:true}) |
| 110 |
|
| 111 |
js> (function(x) { |
| 112 |
> Object.defineProperty(arguments, 0, {enumerable:false}); |
| 113 |
> return Object.getOwnPropertyDescriptor(arguments, 0).enumerable; |
| 114 |
> })("original") |
| 115 |
false |
| 116 |
|
| 117 |
js> (function() { |
| 118 |
> Object.defineProperty(arguments, 0, {value:2, writable:false}); |
| 119 |
> arguments[0] = 3; |
| 120 |
> return arguments[0]; |
| 121 |
> })(1); |
| 122 |
2 |