This content originally appeared on DEV Community and was authored by Can Mingir
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
This content originally appeared on DEV Community and was authored by Can Mingir
Can Mingir | Sciencx (2022-07-23T14:15:00+00:00) Variables and Control Flow. Retrieved from https://www.scien.cx/2022/07/23/variables-and-control-flow/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.