DEV Community

Discussion on: Question: Naming date variables

Collapse
 
athomsfere profile image
Austin French

I'd argue this is the correct way to use Hungarian notation. Especially in JavaScript.

with the caveat that actual usage matters. If this was meant to be a private class for example, I'd prefer to see something like:

   getCalendarevent(id) {
   let selectedEvent =  events[id];

   showEventViewer({
   title: selectedEvent.name,
   dateString: selectedEvent.getDateString(),
   location: selectedEvent.location
  });
}
Enter fullscreen mode Exit fullscreen mode

where the "Event" object looks more like:

  Event = {
  title;
  date;
  location;

  getDateString = function(){
   return this.date.toString();
  }  

}

Enter fullscreen mode Exit fullscreen mode