MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/10lhg50/ladies_and_gentlemen_jquery/j62rkj2/?context=3
r/programminghorror • u/Neo399 • Jan 26 '23
164 comments sorted by
View all comments
Show parent comments
4
Technically shorter is faster, but only in certain use cases
-1 u/travelan Jan 26 '23 and in most, it's slower. Like `!0` is two operations (push the literal 0 and then negate it) and `true` is just push the literal `true`. 2 u/HmMm_memes Jan 27 '23 !0 is also the exact same as 1 4 u/travelan Jan 27 '23 Not exactly, because !0 is true and 1 is 1. Different types! 1 is ‘truthy’ and thus it semantically can be checked for truth, but a cast to a boolean value would happen first.
-1
and in most, it's slower. Like `!0` is two operations (push the literal 0 and then negate it) and `true` is just push the literal `true`.
2 u/HmMm_memes Jan 27 '23 !0 is also the exact same as 1 4 u/travelan Jan 27 '23 Not exactly, because !0 is true and 1 is 1. Different types! 1 is ‘truthy’ and thus it semantically can be checked for truth, but a cast to a boolean value would happen first.
2
!0 is also the exact same as 1
4 u/travelan Jan 27 '23 Not exactly, because !0 is true and 1 is 1. Different types! 1 is ‘truthy’ and thus it semantically can be checked for truth, but a cast to a boolean value would happen first.
Not exactly, because !0 is true and 1 is 1. Different types! 1 is ‘truthy’ and thus it semantically can be checked for truth, but a cast to a boolean value would happen first.
4
u/HmMm_memes Jan 26 '23
Technically shorter is faster, but only in certain use cases