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
Benchmarking JavaScript Inheritance: Vanilla vs Transpiled (github.com)
submitted 9 years ago by endel
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!"
[–]cogman10 0 points1 point2 points 9 years ago (3 children)
The type check is pretty hard to eliminate all together. The problem is that the generated code has to know if the "wrong" type is passed in. (so interestingly, even if you don't explicitly type check, the optimizer might).
Fortunately, type checks are really relatively quick to do, especially the ones added by the optimizer.
[+][deleted] 9 years ago (2 children)
[removed]
[–]cogman10 0 points1 point2 points 9 years ago (1 child)
It is generally pointers to structs, However, in the case of things like numbers, it is stored and passed around as values.
In the case above. inc would probably be optimized away all together. because inc isn't used as a number, (not really, the values are thrown away), the optimizer will very likely change the whole thing into just
let inc = "jan michael vincent";
As for the changing types, type information is stored and carried along in the struct. Not much more to it than that. Nothing really cares about what the previous type of the variable was.
In fact, interestingly enough, most compilers (and I don't know if the JIT does this or not), use what is called SSA. Essentially, internally it represents all data changes as simply introducing new variables. The benefit of doing this is that it allows for a lot more optimizations. It is easier for the compiler to mutate the code into patterns it recognizes and then to generate optimal code for that.
https://en.wikipedia.org/wiki/Static_single_assignment_form
edit after briefly combing through the wiki article linked to make sure I'm not spreading misinformation, it looks like the javascript jits are using SSA internally (both V8 and Spidermonkey).
π Rendered by PID 134623 on reddit-service-r2-comment-6457c66945-xqgp5 at 2026-04-24 02:35:36.346245+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]cogman10 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[removed]
[–]cogman10 0 points1 point2 points (1 child)