Ranter
Join devRant
Do all the things like
				++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
				Sign Up
			Pipeless API
 
				From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
				Learn More
			Comments
		
- 
				
				 monnef3107y@heyheni Yeah, I wanted to avoid more dependencies, but after I found out the JS date API has no way of validating ISO date strings (it accepts many formats which may lead to e.g. swapping day and month) I gave up and used the mentioned moment library (very powerful and way better API). monnef3107y@heyheni Yeah, I wanted to avoid more dependencies, but after I found out the JS date API has no way of validating ISO date strings (it accepts many formats which may lead to e.g. swapping day and month) I gave up and used the mentioned moment library (very powerful and way better API).
- 
				
				@filthyranter ive always assumed it was so you could use the months in a select box, and using the value to map to a month name array alongside it
- 
				
				 crisz81017yBecause they expect you to put month index in an array, like crisz81017yBecause they expect you to put month index in an array, like
 
 var months = ['jan', 'feb', 'mar', ....]
 var month = months[new Date().getMonth()];
 
 This is not needed, instead, for days and years
- 
				
				In recent years there were many new browser apis released, is there one for dates?
 
 Or is there one in web assembly?
 
 (i have no idea, i can't code)
- 
				
				 monnef3107yI don't think it was such a great idea having different bases in parameters of one function. For example I wanted to test some operation on dates: monnef3107yI don't think it was such a great idea having different bases in parameters of one function. For example I wanted to test some operation on dates:
 
 > const d = new Date(2018, 1, 1);
 
 So I was (I would say naturally) expecting to get 1st January 2018. Was greeted with crashing test and a very confusing expected value:
 
 > d.toISOString();
 
 '2018-02-01T00:00:00.000Z'
 
 Where the hell February came from?
 
 JS has a few nasty traps like map:
 
 > ['1', '10', '100'].map(Number.parseInt)
 
 [ 1, NaN, 4 ]
 
 But I think overall it is an alright language. I view PHP as a much much bigger mess.
- 
				
				 sysvinit8327y@filthyranter that 3 words, wtf explains a lot about using JS frameworks (or even just JS itself) 🤣 sysvinit8327y@filthyranter that 3 words, wtf explains a lot about using JS frameworks (or even just JS itself) 🤣
- 
				
				 monnef3107y@irene map passes three arguments (item, index and whole array) and parseInt accepts optional second argument - radix I think. Some attempts at using FP in vanilla JS give very unexpected results. But with good libraries shielding programmer from this occasional traps, I think JS can be quite successfuly used in reasonable FP. monnef3107y@irene map passes three arguments (item, index and whole array) and parseInt accepts optional second argument - radix I think. Some attempts at using FP in vanilla JS give very unexpected results. But with good libraries shielding programmer from this occasional traps, I think JS can be quite successfuly used in reasonable FP.
- 
				
				 monnef3107y@irene I think zero radix gets interpreted by parseInt same way as undefined (= not filled optional argument) so it goes with default radix 10. Magic :) monnef3107y@irene I think zero radix gets interpreted by parseInt same way as undefined (= not filled optional argument) so it goes with default radix 10. Magic :)
Related Rants



 when your code is a mess but everything work out in the end
when your code is a mess but everything work out in the end
 When you keep getting +1s on a rant you posted a month ago.
When you keep getting +1s on a rant you posted a month ago.
 Go big or go home.
Go big or go home.
Another JavaScript API 💎: months are zero-based, but days and years are not. 😒
rant
date
javascript