Java Reference
In-Depth Information
returns the primitive Boolean value wrapped in the object. The Boolean object does not
have any other interesting properties or methods. The following code shows how to use
the Boolean object:
var b1 = Boolean(100); // Assins true to b1
var b2 = Boolean(0); // Assins false to b1
var b3 = Boolean(); // Assigns false to b3
var b4 = new Boolean(true); // Assign a Boolean object to b4
print("Boolean(100) returns " + b1);
print("Boolean(0) returns " + b2);
print("Boolean() returns " + b3);
print("b4.valueOf() returns " + b4.valueOf());
Boolean(100) returns true
Boolean(0) returns false
Boolean() returns false
b4.valueOf() returns true
The Date Object
The Date object is a function. It can be called as a function or constructor. Its signature is:
Date(year, month, date, hours, minutes, seconds, milliseconds)
All parameters in the Date object are optional. When it is called as a function,
it returns the current date and time as a string. You can pass arguments to it when
calling it as a function; however, all arguments are always ignored. When it is called as
a constructor, arguments represent the date components and are used to initialize the
Date object. The following code shows how to use the Date object as a function to get the
current date and time. You may get a different output when you run the code:
// Call Date as a function
print(Date());
print(Date(2014, 10, 4, 19, 2)); // Arguments to Date are ignored
Sat Oct 04 2014 19:07:20 GMT-0500 (CDT)
Sat Oct 04 2014 19:07:20 GMT-0500 (CDT)
The Date object can be called as a constructor passing arguments in the following forms:
new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds,
milliseconds)
 
Search WWH ::




Custom Search