As defined in JavaScript, variables of var
, let
and const
can be used, but only difference is var
is stored automatically, in meanwhile, let
and const
are temporary to its block
app.post("/test", () => {
var a = 1;
return a;
});
app.get("/test", () => {
return a;
});
π‘ Variable definitions without identifier like
a = 1
are upsert operation, also automatically stored.
Control Flow
nucleoid.run(() => {
var a = 1;
var b = a + 2;
var c = b + 3;
});
Once a variable is defined like var a = 1
(this doesn't apply to let
or const
), the runtime does 3 major things. First, it places the var a
in the graph and makes the connection between dependent variables.
Second, updates state with new values in order get affect
State | |
---|---|
var a |
1 |
var b |
3 |
var c |
6 |
However, actual execution is different since variables are tracked in the graph.
state.a = 1;
state.b = state.a + 2;
state.c = state.b + 3;
and finally stores statements in the runtime-managed fs
Top comments (0)