project-owner / Peppy

Peppy Player Repository
GNU General Public License v3.0
72 stars 14 forks source link

Update websocket.js #3

Closed linusg closed 5 years ago

linusg commented 5 years ago

Don't get me wrong, the code worked, but not as one may think. Consider the following self-executing anonymous function:

(function (arg) {
  console.log(arg, undefined != null, undefined !== null);
})()

You'll see the output is:

undefined false true

Which means:

As a shortcut if (arg) can be used, though.

Last but not least, as I told you in the German Raspberry Pi forum before, this is an awesome project! 😃

linusg commented 5 years ago

Ah, and template strings are a much cleaner way of string concatenation than the + operator :wink:

"ws://" + location.host + "/ws"
`ws://${location.host}/ws`
project-owner commented 5 years ago

Thank you Linus for comments. I'll try to fix the indentation in the next release. As for concatenation it's just easier for me - it works the same way almost in all languages :)

On Thu, Jan 24, 2019 at 1:51 AM Linus Groh notifications@github.com wrote:

Ah, and template strings https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/template_strings are a much cleaner way of string concatenation than the + operator 😉

"ws://" + location.host + "/ws" ws://${location.host}/ws

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/project-owner/Peppy/pull/3#issuecomment-457135135, or mute the thread https://github.com/notifications/unsubscribe-auth/APyAdD-zCRPEccIVu-4R-QOtSTIiq5ODks5vGYI9gaJpZM4aQf3d .