DEV Community

Discussion on: Using WebSockets with React

Collapse
 
mzrt profile image
Evgeniy Tortumashev

if ((json.event = "data")) {

Why "=", and not "==="?

Collapse
 
dcsan profile image
dc

Because he's not using a linter?
That's why he gets a lot of unfiltered events.

Collapse
 
muratcanyuksel profile image
Murat Can Yüksel • Edited

Good question, that was some snippet I found while trying to figure out how to get started, and itseemed to work. I didn't even think about it. Will it cause any problems? It didn't so far...

Collapse
 
mzrt profile image
Evgeniy Tortumashev

This condition will always be true because the assignment operator is used instead of the comparison operator.

Thread Thread
 
muratcanyuksel profile image
Murat Can Yüksel

Gonna edit it (y)