Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 4
    What about exporting an object instead, that contains a bunch of functions? Also what would be be the pros and cons of exporting such an object vs exporting a class with static properties? Commented Sep 4, 2017 at 2:00
  • 2
    Using named exports like we are here is just an object being exported. This is why you can destructure on the import. Do import functions from './helpers'. functions. HelloChandu will be there. functions is an object containing all the functions. Read up on export here :) developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… Commented Sep 5, 2017 at 14:16
  • 2
    The con of using a bunch of static properties on a class is that you have a class for no reason. It's like using an api that you don't need. Why would you new up a class just for static properties? Export a function in that case Commented Sep 5, 2017 at 14:17
  • 1
    Stylistically speaking, aren't functions in js usually "lower camel case"? Commented Oct 2, 2019 at 22:36
  • 1
    @JWoodchuck yes you are correct. but it depends. A react component would be a function that has the first letter capital, due to how React + jsx works. But in other cases it seems lower camel is the norm Commented Oct 11, 2019 at 2:32