u/ginger-juliain r/node • Recommends
I ❤ #javascript: Can (a ==1 && a== 2 && a==3) ever evaluate to true in JS?
#javascriptcoercion#typecoercion
1.7K subscribers • 7 videos on Hallway
Intermediate. Assumes working knowledge.
1.4K views8 years ago2 recommendations
Programming languagesJavaScript
Anatol explains how JavaScript type coercion and object-to-primitive conversion can make a variable evaluate to multiple values.
stackoverflow.com/questions/48270127/can-a-1-a-2-a-3-ever-ev… What are your thoughts on the equation below? (a == 1 && a == 2 && a == 3) === true Hold on, you really think it is possible in JavaScript? Don't rush into conclusions. In fact, the answer is yes. Let's clear it up. Hi, let's talk today about the variables acting suspiciously. I'm Anatol and you're watching the Good Parts of the FrontEnd development. First things first. In computer programming, a variable or scalar is a storage location (identified by a memory address) paired with an associated symbolic name (an identifier), which contains some known or unknown quantity of information referred to as a value. Therefore it might be something else besides the primitive types. Put your attention to a double equation. As you know, JavaScript converts the types, so we can simply create an object with a custom “toString” function that changes what it returns each time it's used such that it satisfies all three conditions. Further option when you’re working with an array and pop the values one by one. Additionally we can redefine "valueOf" function as following: Yet another alternative uses a getter inside of a "with" statement. Or even "proxy". Or "define Property" function. And so on. Finally. Do you remember JavaScript accepts UTF for a variable name, don't you? Hence, it might be Latin, Greek, Full width Latin, Cyrillic or even Cherokee characters. The generic term for this is "homoglyphs": different unicode characters that look the same. Moreover, it might contains some hidden characters. That's it. So easy. Maybe too much. If you like this video give it "thumbs up". Thanks for watching and dive deeper. Used: looperman.com: Rosita Lofi Beat by Fanto8BC, Progress by nightingale, Chiptune Melody by L0neW0lf, Film Noir by LankFrampard, Russian Boogie by nightingaleu/ginger-juliain r/node • Recommends
u/dobkin-1970in r/Frontend • Recommends