4 ms·
The site does say so in the introduction > Even if you're a JS developer, most of this syntax is probably, and hopefully, not something you use in your daily l
by wartijn_ 5y ago
The site does say so in the introduction
> Even if you're a JS developer, most of this syntax is probably, and hopefully, not something you use in your daily life.
So I think you should look at this site more as something fun you might not have known if you're an js developer than as criticism of js.
That being said, the !!"" isn't that weird of a syntax is it? I see and use the double exclamation mark all the time.
- leoc 5y ago> that weird of a syntax ought to be "that weird a syntax": it's 'so [adjective] a [noun]' not 'so [adjective] of a [noun]'. It's 'so much of a syntax' but that's because 'much' is a determiner not an adjective, which really makes a much difference. Or if you want to be plain-spoken you can ofc just say 'such a weird syntax'.
- KMnO4 5y agoEnglish is as weird as JavaScript.
- bryanrasmussen 5y agono, it's fine - you just need the right education https://publicdomainreview.org/collection/english-as-she-is-spoke-1884 https://publicdomainreview.org/collection/english-as-she-is-...
- blowski 5y agohttps://english.stackexchange.com/a/30012/7762 https://english.stackexchange.com/a/30012/7762
- leoc 5y agoYes, the quotation from dictonary.com exactly supports what I am saying. It's a piece of spoken dialect not standard English. It's as if I was after using hiberno-English constructions in a HN comment. Will you go on out of that.
- blowski 5y agoIf your comments were comprehensible to most HN readers, I wouldn't see the problem in using Hiberno-English, or any other colloquialisms.
- leoc 5y agoIf you consistently wrote in the way that Goofy talks then most HN readers would understand you just dandy but you wouldn't look no ways good. 'so [adjective] of a [noun]' is a Goofyism which doesn't belong in even middle-register spoken English. (Of course writing in dialect is completely fine if you're doing it for effect or for some other specific reason.)
- blowski 5y agoThat's completely your opinion, though - there's nothing in the guidelines or FAQs that say that. When on HN, I engage with things I find interesting, irregardless of how good their ritten. If we intimidate users with an expected level of ability in written English, we'll be excluding a lot of interesting comments.
- deleted 5y ago[deleted]
- fenomas 5y agoThere is no such thing as standard English. The link says only that the usage is informal, and HN comments are not formal writing.
- zdragnar 5y agoThe output is "weird" if you don't know the rules for operator precedence and how things convert to their primitive values. Most people arent going to "know" what '+!![]' will resolve to because it makes literally no sense to combine those operators into a single expression in anything approaching normal code.
- zarzavat 5y agoI have definitely used the +!! "operator" before. It coerces a value into a boolean integer. It's not weird at all, just a mechanical application of the not ! and Number coercion operators +. The fact that [] is truthy is something everybody learns in their first weeks of JS programming otherwise you would be writing `if (someArray)` and wondering why your code is broken. A weird one would be to explain why +[] is 0 and +{} is NaN. That is nonsensical.
- denton-scratch 5y agoThis is true; a lot of the questions are about automatic type conversions.
- TheCoelacanth 5y agoI doubt that anyone who hasn't written JS will recognize !! as an idiom for converting to boolean.
- tyingq 5y agoThat kind of type coercion predates JS. perl -e 'print !!"whee"' 1 php -r 'print !!"whee";' 1 awk 'BEGIN {print !!"whee"}' 1
- bostonsre 5y agoPoor frontend devs.. stuff like this has to result in incredibly painful debugging because of assuming code would act one way when it does something else entirely. > the !!"" isn't that weird of a syntax is it? Why would someone say not not empty string in code somewhere? Or do you mean seeing !!var_that_could_have_empty_string isn't too weird?
- ulisesrmzroche 5y agoThat's what tests and code review is for. Truth is that if any of this kinda code gets into prod, then you got bigger problems than some arcane JS gotchas.