Variables and Control Flow

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(“/te…


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.

Variable Graph

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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Variables and Control Flow." Can Mingir | Sciencx - Saturday July 23, 2022, https://www.scien.cx/2022/07/23/variables-and-control-flow/
HARVARD
Can Mingir | Sciencx Saturday July 23, 2022 » Variables and Control Flow., viewed ,<https://www.scien.cx/2022/07/23/variables-and-control-flow/>
VANCOUVER
Can Mingir | Sciencx - » Variables and Control Flow. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/23/variables-and-control-flow/
CHICAGO
" » Variables and Control Flow." Can Mingir | Sciencx - Accessed . https://www.scien.cx/2022/07/23/variables-and-control-flow/
IEEE
" » Variables and Control Flow." Can Mingir | Sciencx [Online]. Available: https://www.scien.cx/2022/07/23/variables-and-control-flow/. [Accessed: ]
rf:citation
» Variables and Control Flow | Can Mingir | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.