forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLength.js
More file actions
62 lines (41 loc) · 1.79 KB
/
Length.js
File metadata and controls
62 lines (41 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function write(v) { WScript.Echo(v + ""); }
var o = new Object();
o.length = 10;
write(o.length + " " + o["length"] + " " + o["len" + "gth"]);
o.length = 20;
write(o.length + " " + o["length"] + " " + o["len" + "gth"]);
var s = "Hello World";
write(s.length + " " + s["length"] + " " + s["len" + "gth"]);
var x = s.length = 30;
write(x);
write(s.length + " " + s["length"] + " " + s["len" + "gth"]);
var o1 = new Object();
var a = [1000,2000,3000];
// Normal index
write(a[0] + " " + a["0"] + " " + a[0.0]);
// 'x' Expando
a.x = 40;
write(a.x + " " + a["x"]);
// object o as expando
a[o] = 50;
write(a[o] + " " + a[o1] + " " + a["[object Object]"] + " " + a["[object" + " Object]"]);
// array length
write(a.length + " " + a["length"] + " " + a["len" + "gth"]);
a.length = 60;
write(a.length + " " + a["length"] + " " + a["len" + "gth"]);
a["length"] = 70;
write(a.length + " " + a["length"] + " " + a["len" + "gth"]);
a["le" + "ngth"] = 80;
write(a.length + " " + a["length"] + " " + a["len" + "gth"]);
function foo() {};
write(foo.length + " " + foo["length"] + " " + foo["len" + "gth"]);
function foo1(x) {};
write(foo1.length + " " + foo1["length"] + " " + foo1["len" + "gth"]);
function foo2(x,y,z) {};
write(foo2.length + " " + foo2["length"] + " " + foo2["len" + "gth"]);
eval("function foo3(x,y){};");
write(foo3.length + " " + foo3["length"] + " " + foo3["len" + "gth"]);