I thought and and or worked the same everywhere. They don’t. Same idea. Very different outputs 🧠 What this means Same operators… different behavior: Python → returns values JavaScript → returns values C/C++ → returns 0/1 Java → strict boolean only ⚠️ Why this matters If you switch languages: 👉 Your code might “work”… 👉 but behave very differently 🎯 One-line takeaway 👉 and / or are not universal — they follow the rules of the language you’re in What language surprised you the most with this? #Python #JavaScript #Programming #Coding #Developers #LearningInPublic
I still cannot figure out how python works...
For Java it’s 0&5 not 0 && 5 There’s a difference between & which is used in bitwise and logical and while && is only used for the logical and one For C/Cpp && and || work with variable like if they have value or not For || it means at least one is ≠0 or true For && it means both are true or ≠0 For Python and it returns the first false one aka zero otherwise it returns the last one For or it returns the first true aka non zero For JS I don’t know