# Category: javascript

## How do I convert ISO date format to yyyy-MM-dd format using momentjs or vanilla JS?

I’m trying to hit a soccer sports API which includes date in the format of yyyy-mm-dd, only the scores from that date to current date will be displayed. The current date is chosen by user using a calendar but when the user chooses the date from calendar, it gets displayed in ISO format as “Fri Aug 17 2018 00:00:00 GMT +0545 (Nepal Time)” . I want to convert this date in the front end in […]

## AngularJS filter refresh for placeholder

I am using filter to localize my page. AngularJS filters only refresh when the key is changing unless they are expressions (or objects) and then they are evaluated on every digest cycle. https://docs.angularjs.org/guide/filter So instead of writing this: <div>{{‘name’ | localFilter}}</div> I used a little trick and wrote the ‘name’ as expression to trigger filter refresh on every digest cycle. I defined variable localize=true <div>{{localize && (‘name’ | localFilter)}}</div> and it worked. BUT it doesn’t […]

## How to check chain of hasOwnProperty in objects

I have json like this var a = { “name”: “test1”, “redisData”: { “redisIp”: “127.0.0.1”, “dbSetting”: { “dbIp”: “127.0.0.1”, “dbUserName”: “root”, “dbUserPassword”: “root”, }, “otherData”:{ “email”:”[email protected]” } } } So i have to push this data in database when all the data present in all key for that purpose i have to validate that data like this if (a.hasOwnProperty(“redisData”)) { if (a.redisData.hasOwnProperty(“dbSetting”)) { if (a.redisData.dbSetting.hasOwnProperty(“dbIp”)) { if (a.redisData.dbSetting.dbIp) { // now insert in to database […]