KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What's the difference between & and && in JavaScript? Example code: var first = 123; var second = false; var third = 456; var fourth = "abc"; var fifth = true; alert(first & second); // 0 alert(first & third); // 72 alert(first & fourth); // 0 alert(first & fifth); // 1 alert(first && second); // false alert(first && third); // 456 alert(first && fourth); // abc alert(first && fifth); // true It seems like && is a logical and which gives me always the second value if both are true . But what is & ? (By the way, && seems to be and in Python; & seems to be & in Python)
Tags (comma-separated)
Save Edits
Cancel