Languages
[Edit]
EN

TypeScript - day name for the first day of month

0 points
Created by:
Diana
720

In this article, we would like to show you how to get the first day name of the indicated month in TypeScript.

Quick solution:

Where in the above code, we:

  1. use an array with names of the weekdays,
  2. create a date that represents the first day in the month - it is Date(year, month, 1),
  3. get day index in the week using getDay() method - it counts days from 0 to 6, staring from Sunday,
  4. get the day name from the array using the day index.

 

Reusable code example

Edit

    Output:

    1
    Donate to Dirask
    Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
    Join to our subscribers to be up to date with content, news and offers.
    Native Advertising
    🚀
    Get your tech brand or product in front of software developers.
    For more information Contact us
    Dirask - we help you to
    solve coding problems.
    Ask question.

    ❤️💻 🙂

    Join