« first day (4271 days earlier)      last day (662 days later) » 

1:23 AM
Why would new Date('01/01/2020'); return a date instance of 2020-01-01T05:00:00.000Z while new Date('2020-01-01'); returns 2020-01-01T00:00:00.000Z? Does the format of the date change whether it takes in consideration a certain timezone or something along those lines?
Even more interestingly, new Date('2022-01-01 00:00:00'); also returns 2020-01-01T05:00:00.000Z (5 hours ahead), so it must be that it is taking the time zone in consideration (timezone at that point was -5)
Just really not intuitive behavior on whether it takes the timezone in consideration or not
 
 
3 hours later…
4:25 AM
Hi Guys, I answered a question related to Angular and it is working as expected and even guy who asked the question also accepted the same .. but i don't know why others are having issues and downvoting it .
 
@AshishGoyal Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
-3
A: Access an API from Angular

Ashish GoyalHere, Please try to create a new method and use async/await. Create a new method something like this - public async getData() { await this.http.get(this.URL) .toPromise() .then(response => this.datas = response['records']) .catch(err => { console.log ('error'); }); } Now...

it is downgrading my score and not encouraging to downvote working solution.
 
 
3 hours later…
6:56 AM
@scorgn Only "2020-01-01" is a valid spec compliant date format. "01/01/2020" is not. Its handling is implementation-dependent. It can be read as local timezone or as UTC. Or might just be interpreted as a different date entirely or even as not a valid date.
34
Q: What are valid Date Time Strings in JavaScript?

strWhen using new Date or Date.parse in JavaScript, I cannot just pass arbitrary date formats. Depending on the format, I get a different date than I wanted to or even Invalid Date instead of a date object. Some date formats work in one browser but not in others. So which date time formats should I ...

@scorgn It is documented You don't have to guess or intuit it. Having used multiple date APIs, you should never guess or intuit how a string date should be handled. Never, ever. Because you never can accurately do that.
 
 
8 hours later…
2:57 PM
Hello
What's the best approach to check if an array contains an object of values ?
.includes or .indexOf ?
 
Neither of these will find an object in an array
You can use .some() to find if something exists, or find() to retrieve it. findIndex if you need its index
|| mdn array some
 
|| mdn array find
 
||mdn array findindex
 
Great
So , if I want to check if firstName: '1', lastName: '1'} exist in array
It's recommended to use .some()
 
Yes.
 
const index = state.favorites.some(action.payload);
Hmm, then this solution is not good
I am trying to debug , but it's skipped
 
.some() accepts a callback
.some(x => x.firstName === action.payload.firstName && x.lastName === action.payload.lastName)
 
Thank you
 
 
2 hours later…
4:50 PM
I am trying to set default value of input type date
with react-hook-form
like this
    defaultValues: {
      birthDate: editData?.birthDate || "",
    },
but it's still empty
What I am missing
?
 
 
1 hour later…
5:57 PM
@MileMijatović Does editData?.birthDate result in a falsy value?
 
6:23 PM
No
value is truthy
@VLAZ
Thu Mar 04 1965 00:00:00 GMT+0100 (Central European Standard Time
in this format
but it's not applied as defaultValue on edit form
Any idea how to fix that ?
 
 
4 hours later…
10:21 PM
ain't one supposed to pass ISO8601 date strings as values of date inputs?
setting value of an input with type date to a string that does not conform to that usually clears the input instead, which I highly suspect is what is happening here
 

« first day (4271 days earlier)      last day (662 days later) »