JavaScript apply() method

The Javascript handler applies () method traps for a function call. Syntax: apply: function(target, thisArg, arguments) Parameters: target: It represents the target object. thisArg: It represents this keyword for the function call. argumentsList: The list of function parameters. Return: Any value. Example: <!DOCTYPE html> <html> <body> <script> var handler = function(a, b) { document.writeln(‘proxy: ‘ … Read more

JavaScript handler

Javascript facilitates a number of handler methods in order to improve the ease of programming. These are: apply() method: Use: To trap for a function call. construct() method: Use: To intercept the new operation. defineProperty() method: Use: To define the new properties and to modify the existing properties. deleteProperty() method: Use: To remove a property … Read more

JavaScript toUTCString() method

The JavaScript date toUTCString() method is used to get the particular date in the form of a string using the UTC time zone. Syntax: dateObj.toUTCString(); Return: String representation of date portion of a Date object UTC time zone. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toUTCString()); </script> </body> </html>

JavaScript toTimeString() method

The JavaScript date toTimeString() method is used to get the time portion of a Date object. Syntax: dateObj.toTimeString(); Return: String representation of the time portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toTimeString()); </script> </body> </html>

JavaScript toString() method

The JavaScript date toString() method is used to get the date in the form of a string. Syntax: dateObj.toString(); Return: String representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toString()); </script> </body> </html>

JavaScript toJSON()

The JavaScript date toJSON() method is used to get a string representing the Date object and serializing the Date object at the time of JSON serialization. Syntax: dateObj.toJSON(); Return: String representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toJSON()); </script> </body> </html>

JavaScript toISOString()

The JavaScript date toISOString() method is used to get the date in the form ISO format string. Syntax: dateObj.toISOString(); Return: ISO format string representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toISOString()); </script> </body> </html>

JavaScript toDateString()

The JavaScript date toDateString() method is used to get the date portion of a Date object. Syntax: dateObj.toDateString(); Return: String representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toDateString()); </script> </body> </html>

JavaScript setUTCSeconds()

The JavaScript date setUTCSeconds() method sets the second value for the particular date on the basis of universal time. Syntax: dateObj.setUTCSeconds(new_seconds); Parameters: new_seconds: Integer value between 0 to 59. Example: <!DOCTYPE html> <html> <body> <script> var today =new Date(); document.writeln(today.getUTCSeconds()+”<br>”); today.setUTCSeconds(40); document.writeln(today.getUTCSeconds()); </script> </body> </html>