Giter VIP home page Giter VIP logo

Comments (8)

goldbergyoni avatar goldbergyoni commented on May 5, 2024 2

@syzer why not PR it? I can do myself if you're busy

from nodebestpractices.

goldbergyoni avatar goldbergyoni commented on May 5, 2024

Great anecdote.

I would vote for removing that - a best practice should provide some practical value, it seems pointless in this case. Let's let it park here for few days and see if there are other thoughts. Case not, let's PR it.

from nodebestpractices.

syzer avatar syzer commented on May 5, 2024

Also i would change single quoted strings to strings literals:

const config = {
   key: 'value'
}

to

const config = {
   key: `value`
}

It had a performance impact on old versions of node... but that's not an issue anymore.

from nodebestpractices.

syzer avatar syzer commented on May 5, 2024

here #81 :)

from nodebestpractices.

refack avatar refack commented on May 5, 2024

It had a performance impact on old versions of node... but that's not an issue anymore.

It may not be noticeable, but it's there. It also implies a different semantic. Do you have any references to preferring only ` over the combination with '?

from nodebestpractices.

syzer avatar syzer commented on May 5, 2024

I can replace ` with ' if you want , however:
template literals allow string interpolation

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

When one add two objects: obj1 + obj2 it works in different way than one might think.
consider this object:

const obj = { valueOf() {return 5}, toString() {return ''} }

now:

typeof (obj + 5) !== typeof `${obj}5`
obj + '42' !== `${obj}42`

When ppl see value, they expect to have a string type, however adding with + will leave good attack vector, or/and potential instability of system.

So using template literals for strings is a good idea. That's why they were introduced in es 2015.

from nodebestpractices.

BrunoScheufler avatar BrunoScheufler commented on May 5, 2024

Although I do see the point you mentioned above, I would prefer using normal strings with single/double quotes by default and template literals only for parts where interpolation is needed. Many style guides also use this pattern, so I think we should really take another look at this change and maybe vote for this.

from nodebestpractices.

stale avatar stale commented on May 5, 2024

Hello there! 👋
This issue has gone silent. Eerily silent. ⏳
We currently close issues after 100 days of inactivity. It has been 90 days since the last update here.
If needed, you can keep it open by replying here.
Thanks for being a part of the Node.js Best Practices community! 💚

from nodebestpractices.

Related Issues (20)

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.