-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathequal_object.js
55 lines (43 loc) · 1.46 KB
/
equal_object.js
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
//-------------------------------------------------------------------------------------------------------
// 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(args)
{
WScript.Echo(""+args);
}
var o = {toString: function(){write("Inside toString"); return "abc";}, valueOf: function(){write("Inside valueOf");return 10;}};
write("Scenario 1");
write(o==10);
write(o=="abc");
write(10==o);
write("abc"==o);
write("Scenario 2");
o = {valueOf: function(){write("Inside valueOf"); return 1;}};
write(o==true);
write(o==false);
write(true==o);
write(false==o);
write("Scenario 3");
var o = {valueOf: function(){write("Inside valueOf"); return 0;}};
write(o==true);
write(o==false);
write(true==o);
write(false==o);
write("Scenario 4");
o = {toString: function(){write("Inside toString"); return "1";}};
write(o==true);
write(o==false);
write(true==o);
write(false==o);
write("Scenario 5");
o = {toString: function(){write("Inside toString"); return "0";}};
write(o==true);
write(o==false);
write(true==o);
write(false==o);
write("Scenario 6");
var dtBegin = new Date("Thu Aug 5 05:30:00 PDT 2010");
var dtCurrentBegin=dtBegin.getTime();
write(dtCurrentBegin == dtBegin);
write(dtBegin == dtCurrentBegin);