DEV Community

Can Mingir for Nucleoid

Posted on • Edited on

5 2

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("/test", () => {
  return a;
});
Enter fullscreen mode Exit fullscreen mode

💡 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;
});
Enter fullscreen mode Exit fullscreen mode

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;
Enter fullscreen mode Exit fullscreen mode

and finally stores statements in the runtime-managed fs

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay