get the name of month without using hard coded arrays in javascript

Solutions on MaxInterview for get the name of month without using hard coded arrays in javascript by the best coders in the world

showing results for - "get the name of month without using hard coded arrays in javascript"
Nicole
12 May 2019
1'use strict';
2
3(function(d){
4    var mL = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
5    var mS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
6
7    d.prototype.getLongMonth = d.getLongMonth = function getLongMonth (inMonth) {
8        return gM.call(this, inMonth, mL);
9    }
10
11    d.prototype.getShortMonth = d.getShortMonth = function getShortMonth (inMonth) {
12        return gM.call(this, inMonth, mS);
13    }
14
15    function gM(inMonth, arr){
16        var m;
17
18        if(this instanceof d){
19            m = this.getMonth();
20        }
21        else if(typeof inMonth !== 'undefined') {
22            m = parseInt(inMonth,10) - 1; // Subtract 1 to start January at zero
23        }
24
25        return arr[m];
26    }
27})(Date);
28
Henry
18 Oct 2016
1//Assume that cuurent month is December results are given
2
3var getmonth  = new Date().toLocaleString("en-us", { month: "short" });
4console.log(getmonth);
5//result =Dec
6
7
8var getmonth  = new Date().toLocaleString("en-us", { month: "long" });
9console.log(getmonth);
10
11//result= December
12
13
14var getmonth  = new Date().toLocaleString("en-us", { month: "narrow" });
15console.log(getmonth);
16
17//result=D
queries leading to this page
array of months name jsarray of months lengthmonths as a list javascriptmonths of the year javascript arrayjs monthsjavascript months array find numberjs months arrayarray of months jsjs months arayget the array of all months of current year in jsjs get months listjs get array of monthsmonths list jshow to get array of all months using jsmonth array jsmonths array list javascriptget the name of month without using hard coded arrays in javascriptlist of months jsjavascript months listdisplay months in jsjavascript array of monthsjs month arraylist of months in javascriptarray of months javascripthow to get all months in angularget 12 months in array javascriptmonths arraymonths js arraymonth name short array javascripthow to create month array in javascriptarray javascript months in the yearjs array of monthsmonth short form arraymonth array in javascripthow to create an array of months in jsjs getmonth 28 29month array from the array of dates extract months in javascriptmonth array javascriptjs array of dates need to get the months onlyjs get list of monthsget array of months in ajvascriptjavascript create array of monthsjavascript month date arrayjavascript generate array of monthsmonths array list with value javascriptjavascript month arrayjavascript get months arrayarray of full months javascriptjs array of monthmonth array in jshow to store months in arraymonths array in javascriptarray of months in jsjavascript months arrayjs get a list of monthsmonths list in jsgenerate a array of 12 months of a year in javascriptget list of months javascriptarray of all months in jsmonths array javascriptjavascript array for monthsarr of months jsjavascript list monthsjavascript monthsjs date months list 5carray of montshjs months array listmonth arrayall months in array javascriptjavascript list of all monthsjavascript array month nameslist of months javascriptall month array javascricptmonth name array javascriptjavascript array all monthget list of month javacriptjavascript get month arrayget the name of month without using hard coded arrays in javascript