JS/TS Bytecode Visualizer

See how your code transforms into AST, bytecode instructions, and English narration

Source Code

TypeScript / JavaScript

AST

Abstract Syntax Tree

VariableDeclaration { kind: "const" }
declarations: [
VariableDeclarator
]
VariableDeclaration { kind: "const" }
declarations: [
VariableDeclarator
]
VariableDeclaration { kind: "const" }
declarations: [
VariableDeclarator
]
ExpressionStatement
expression: CallExpression
arguments: [
Identifier { name: "sum" }
]
callee: MemberExpression

Bytecode

Stack-based instructions

00|DECLARE_VAR num
01|PUSH_CONST 6
02|STORE_VAR num
03|DECLARE_VAR doubled
04|LOAD_VAR num
05|PUSH_CONST 2
06|MUL
07|STORE_VAR doubled
08|DECLARE_VAR sum
09|LOAD_VAR num
10|LOAD_VAR doubled
11|ADD
12|STORE_VAR sum
13|LOAD_VAR sum
14|LOAD_VAR console
15|CALL_METHOD console log 1
16|POP

English

Human-readable narration

Declare a new variable named 'num'.
Push the constant value 6 onto the stack.
Pop the top of the stack and store it in the variable named 'num'.
Declare a new variable named 'doubled'.
Load the value of 'num' and push it onto the stack.
Push the constant value 2 onto the stack.
Pop the top two values, multiply them, and push the result.
Pop the top of the stack and store it in the variable named 'doubled'.
Declare a new variable named 'sum'.
Load the value of 'num' and push it onto the stack.
Load the value of 'doubled' and push it onto the stack.
Pop the top two values, add them, and push the result.
Pop the top of the stack and store it in the variable named 'sum'.
Load the value of 'sum' and push it onto the stack.
Load the value of 'console' and push it onto the stack.
Call the method 'log' on 'console' with 1 argument(s).
Pop and discard the top value from the stack.