Giter Club home page Giter Club logo

Comments (4)

jashkenas avatar jashkenas commented on June 7, 2024 1

So, perhaps the style guide should say that although there is no such thing as a constant in JavaScript ... if you're using a variable as a constant, you may choose to put it in ALL_CAPS to communicate this.

@mjrusso: By the way, if you end up publishing this style guide online in a pretty HTML version (I'd recommend using the gh-pages branch), I'd be glad to link to it from coffeescript.org

from coffeescript-style-guide.

mjrusso avatar mjrusso commented on June 7, 2024

To simplify the overall discussion, I would like to broaden the scope of this ticket to include some of @jashkenas' comments from #2 re: the naming of constants:

For constants, use all uppercase with underscores

I don't think that this one is settled quite yet. In JavaScript, of course, until const lands, there's no such thing as a constant. For that reason, I think that simply using local variable style for constants may actually make more sense. I'm not sure which should be prescribed.

from coffeescript-style-guide.

showell avatar showell commented on June 7, 2024

I see the point that @jashkenas makes. I know that JS doesn't enforce true constants, but I like the ALL_CAPS convention for variables that are effectively read-only. Certainly, things like PI or FACEBOOK_API_ID should be ALL_CAPS, correct?

The biggest challenge for naming collisions is function names at top level scope. They can collide with local variable names in more narrow scopes. For me, the best resolution is to make sure that function names are distinct from local variable names in general, so all function names should include a verb, i.e prefer calculate_area to area for a function name.

from coffeescript-style-guide.

showell avatar showell commented on June 7, 2024

@jashkenas Yup, I think that's a good way to word it...put the emphasis on the fact there are no such things as a constant, and say that ALL_CAPS is only a convention or hint of intent.

from coffeescript-style-guide.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.