DEV Community

Discussion on: Naming Variables the Right Way

Collapse
 
ronnewcomb profile image
Ron Newcomb • Edited

Agreed. I'd add that functions should be named after verbs (or verb phrases) and classes / objects / values after nouns, but I think everyone intuits that anyway.

For variables holding a promise I'll use the gerund (-ing) form of the function which created it:

var gettingInvoices = getInvoices(custId);  // returns a Promise
//  later... 
var invoices = await gettingInvoices; 
Enter fullscreen mode Exit fullscreen mode

But it's rare that I would need to do so. I did find that showing this naming convention to someone who was new to Promises helped them avoid situations where they've accidentally made a call block on another's return without needing to.