jeudi 3 octobre 2019

join("") invoked upon a string-array with only one element. Purpose?

I have seen this code in a video-tutorial:

const navToggle = ["<div id='toggle-menu'>Menu</div"].join("");
$(".site-header").prepend(navToggle);

I understand what the basically does. But what I don't get is the join-invocation.

What's the purpose of join here?

Wouldn't be ...

const navToggle = ["<div id='toggle-menu'>Menu</div"].join("");
$(".site-header").prepend(navToggle);

... the same?




Aucun commentaire:

Enregistrer un commentaire