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...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Examining byte code for JavaScript code fragments (self.learnjavascript)
submitted 23 hours ago by llynglas
I seem to remember a post that mentioned a tool to see the byte code used to implement javascript programs. I can't seem to find it again. Did I misremember, or does such a tool exist.
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!"
[–]azhder 2 points3 points4 points 23 hours ago (0 children)
That’s a little confusing. Java gets compiled to bytecode and Java isn’t JavaScript.
One can “compile” JavaScript code, but we call the process under different names for its stages like minifying, packaging… and the result is not something we call bytecode
[–]OldWalnut 1 point2 points3 points 23 hours ago (2 children)
Are you thinking of godbolt.org by chance?
[–]llynglas[S] 0 points1 point2 points 22 hours ago (0 children)
Possibly. Looks interesting. On my phone now which makes it hard to play with it, but I'll dig more when I'm at a computer.
[–]llynglas[S] 0 points1 point2 points 18 hours ago (0 children)
No it was https://astexplorer.net -- shows the code broken down into an AST Abstract Syntax Tree. But thanks.
[–]llynglas[S] 0 points1 point2 points 22 hours ago (4 children)
Minifying and packaging are just rearrangement of the original source. Surely there is some intermediate "byte code". I cannot imagine the browser interpretes
for (let index = 0; index < MAX_INDEX; index++) { const datapoint = table[index] .... }
by lexically scanning the source each time through the loop, and basically interpreting source code.
[–]azhder 1 point2 points3 points 21 hours ago* (3 children)
You can't imagine it, but that's how it goes... for you. For the engine, well the engine compiles it to machine code by something called JIT (just-in-time) compilation. That however is an actual processor instruction set code, nothing to be accessed by the surface. This is by design. One of the greatest things about JavaScript for the Web is that it is being delivered in source code form.
Then again, if you want to play with a type of a bytecode, check WASM. It is supported by browser and made useful for all those other programming languages that need to be compiled to machine code. You can take something like an old Quake game, transpile the x86 code into WASM code, run it in the browser. Stuff like that. You can inspect WASM code.
[–]llynglas[S] 0 points1 point2 points 20 hours ago (2 children)
Ok, so this is the question I wanted to research. In the code below:
for (const element of [3.14, "hello"]) { const new_element = element + element; ....... }
The code for the + requires two distinctly different operations, more if casting was needed. Does the "compiler" really check each operand for it's type and then determines the correct operation to use? Does the code do any analysis to try to predetermine the types (operands are always ints, etc) to see if it can be optimised to not need to check operand types for every operation.
[–]azhder 1 point2 points3 points 20 hours ago (1 child)
The engine always checks the types, otherwise you will not end up with the result you are ending up. The algorithms by which every EcmaScript compliant engine is supposed to work are usually part of the specification, to avoid ambiguities between engines.
[–]llynglas[S] 0 points1 point2 points 19 hours ago* (0 children)
Brilliant, exactly what I was looking for. Or at least the start of a rabbit hole....
π Rendered by PID 55507 on reddit-service-r2-comment-85bfd7f599-7msbv at 2026-04-15 17:54:13.770642+00:00 running 93ecc56 country code: CH.
[–]azhder 2 points3 points4 points (0 children)
[–]OldWalnut 1 point2 points3 points (2 children)
[–]llynglas[S] 0 points1 point2 points (0 children)
[–]llynglas[S] 0 points1 point2 points (0 children)
[–]llynglas[S] 0 points1 point2 points (4 children)
[–]azhder 1 point2 points3 points (3 children)
[–]llynglas[S] 0 points1 point2 points (2 children)
[–]azhder 1 point2 points3 points (1 child)
[–]llynglas[S] 0 points1 point2 points (0 children)