JavaScript Set Methods

The new Set() Method

Pass an array to the new Set() constructor:

Example

// Create a Set
const letters = new Set(["a","b","c"]);

The add() Method

Example

letters.add("d");
letters.add("e");

If you add equal elements, only the first will be saved : Continue reading JavaScript Set Methods

JavaScript Set Date Methods

Set Date methods let you set date values (years, months, days, hours, minutes, seconds, milliseconds) for a Date Object.

Set Date Methods

Set Date methods are used for setting a part of a date:

Method Description
setDate() Set the day as a number (1-31)
setFullYear() Set the year (yyyy)
setHours() Set the hour (0-23)
setMilliseconds() Set the milliseconds (0-999)
setMinutes() Set the minutes (0-59)
setMonth() Set the month (0-11)
setSeconds() Set the seconds (0-59)
setTime() Set the time (milliseconds since January 1, 1970)

The setFullYear() Method

The setFullYear() method sets the year of a date object. In this example to 2020 : Continue reading JavaScript Set Date Methods