
Software Engineer | Tech Twitterπ¨βπ» | self-taught | #JavaScript π | #TypeScript π | #Reactjs π§‘| Ask me about JS, TS, React & Front End π¨βπ» #TechLover π
- Tweets643
- Following302
- Followers57
- Likes965
![// Joining an array with four different ways const a = ["Get", "Set", "Go"]; console.log(a.join()); // 'Get,Set,Go' console.log(a.join(", ")); // 'Get, Set, Go' console.log(a.join(" + ")); // 'Get + Set + Go' console.log(a.join("")); // 'GetSetGo' // Using join() on sparse arrays console.log([1, , 3].join()); // '1,,3' console.log([1, undefined, 3].join()); // '1,,3' // Calling join() on non-array objects const arrayLike = { length: 3, 0: 2, 1: 3, 2: 4, }; console.log(Array.prototype.join.call(arrayLike)); // 2,3,4 console.log(Array.prototype.join.call(arrayLike, ".")); // 2.3.4](https://pbs.twimg.com/media/Fxwuf0FX0AIgbLT.jpg?name=small&format=webp)
ALT // Joining an array with four different ways const a = ["Get", "Set", "Go"]; console.log(a.join()); // 'Get,Set,Go' console.log(a.join(", ")); // 'Get, Set, Go' console.log(a.join(" + ")); // 'Get + Set + Go' console.log(a.join("")); // 'GetSetGo' // Using join() on sparse arrays console.log([1, , 3].join()); // '1,,3' console.log([1, undefined, 3].join()); // '1,,3' // Calling join() on non-array objects const arrayLike = { length: 3, 0: 2, 1: 3, 2: 4, }; console.log(Array.prototype.join.call(arrayLike)); // 2,3,4 console.log(Array.prototype.join.call(arrayLike, ".")); // 2.3.4






![const fruits = ['apple', 'banana', 'orange']; const fruitsString = fruits.toString(); console.log(fruitsString); // Output: "apple,banana,orange" const arr = []; arr.join = 1; // re-assign `join` with a non-function console.log(arr.toString()); // [object Array]](https://pbs.twimg.com/media/FxjJHMFXsAMKb87.jpg?name=small&format=webp)






