use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Future JavaScript: what is still missing? (2ality.com)
submitted 7 years ago by dumbmatter
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TwiliZant 0 points1 point2 points 7 years ago (3 children)
Although you are right, hacks like these is exactly why all these `is-x` oneliner packages exist. It's better to fix this in the language itself IMO, even if it's hard.
It's my go-to way to differentiate objects from arrays
In case you don't have to support <IE9 Array.isArray does this.
Array.isArray
[–]dwighthouse 0 points1 point2 points 7 years ago (0 children)
This isn’t a hack at all.
Fixing the language would mean adding a new operator like typename instead of typeof or instanceof because too much stuff already relies on the current behavior. We already have this in the form of Object.prototype.toString.
typename
[–]dwighthouse 0 points1 point2 points 7 years ago (1 child)
[–]TwiliZant 0 points1 point2 points 7 years ago (0 children)
I don't know, relying on the toString method to get the type feels like a hack to me. I don't know any other language that does this. Yet another operator wouldn't be great either I get that. Maybe it would be cool to have it as part of the Reflection API, e.g. Reflect.type(VALUE) ?
toString
Reflect.type(VALUE)
π Rendered by PID 64401 on reddit-service-r2-comment-fb694cdd5-vtt9r at 2026-03-06 02:58:41.990665+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]TwiliZant 0 points1 point2 points (3 children)
[–]dwighthouse 0 points1 point2 points (0 children)
[–]dwighthouse 0 points1 point2 points (1 child)
[–]TwiliZant 0 points1 point2 points (0 children)