8

Still using + to concatenate strings in JavaScript in 2022?

That's cute.

Comments
  • 2
    outdated af*
  • 3
    $ npm install string-concat --save

    const stringConcat = require('string-concat');

    let result = stringConcat( "Hello", " ","world");
    console.log(result);

    // Returns: Hello World
  • 6
    next up:

    $ npm install compare-numbers

    var compareNumbers = require("compare-numbers");

    compareNumbers.asc(10, 1); // 1
    compareNumbers.asc(1, 10); // -1
    compareNumbers.asc(10, 10); // 0

    because using < <= > >= == is sooooo legacy
  • 4
    Context is everything.

    I’d say it’s ok to concatenate 2 short strings with the + operator. In most cases it’s more readable and the performance loss is negligible.

    And if the "modern" style requires a dependency, it’s also a big disadvantage.
  • 0
    let start = "I'm definitely",

    end = "not doing this."

    console.log(`${start} ${end}`)
  • 1
    I'd say it's inconsiderate, if it's meant for potentially translatable strings. Other than that - KISS.
  • 2
    What’s wrong with using +?
  • 2
    Template literals? And what’s wrong with “+”?
  • 0
    You are still using JavaScript?

    That's cute.
Add Comment