Javascript construct in string concatenation

Below is a simple javascript snippet:

var mystring = ("random","ignored","text","h") + ("ello world")

This line leads to the world of hello. I have two questions:

  • what is the name of the (random, ignored, text, h) construction (is it not an array because the array has different types of brackets?)
  • Can someone technically explain why this line leads to a greeting world? (i.e. why only the β€œh” character is taken into account in the design)?
+4
source share
1 answer

You fall into a little-known

, , . , ('foo', 'bar') 'bar'. , , (foo(), bar()) foo(), bar() , bar().

, :

var mystring = ("random","ignored","text","h") + ("ello world")
var mystring = "h" + ("ello world")
var mystring = "h" + "ello world"
var mystring = "hello world"

( ) , . ES6 lambdas reduce, , :

[{key: 'a', value: 1}, {key: 'b', value: 2}].reduce((p, c) => (p[c.key] = c.value, p), {})

, , ( ) .

+9

All Articles