Mental Model of JavaScript
My new mental model of JavaScript after finishing the course Just JavaScript.

Just a guy who loves to write code and watch anime.
Search for a command to run...
My new mental model of JavaScript after finishing the course Just JavaScript.

Just a guy who loves to write code and watch anime.
My name is Olivia and I am a professional writer. I teach people how to reveal their talent in writing. https://34.ua/den-ukrainskoj-pismennosti-7-samyh-vydayushchihsya-ukrainskih-pisatelej-i-poetov_n83050
Great article! Appreciate your input! Your Insta Follower :)
Qualities that make outstanding builders.

Bipedal vs quadrupedal: how many legs This is about the number of legs the creature walks on. Bipedal. Two legs. Humans, ostriches, T-rex, kangaroos, most fantasy humanoids. Quadrupedal. Four legs. Do

Intro You hear "lerp" and "smoothstep" everywhere in game dev. They sound like math jargon. They're not. Both are small tools that do the same job: smoothly move from one value to another. The problem

What is Kinematics Kinematics is the math field. It's the study of how things move without worrying about forces (which would be dynamics). FK and IK are the two branches: forward kinematics and inver

Intro Textures are usually the biggest cost in a 3D scene. Memory, bandwidth, and load time all get eaten by them. Resizing them is the obvious lever. There's more. This post is about the less obvious

I just finished the course Just JavaScript.
I learned several things and my mental model of JavaScript has been rebuilt.
I took notes and decided to write an article mixed with my notes, code and some diagrams.
let a = "Dog"
In the code example above, the variable a is a wire that points to the string Dog.
A diagram below to clarify:

let a = "Dog"
let b = a
In the code example above, the variable (wire) a points to the string Dog in memory. The variable (wire) b looks up the value of the variable a, and then points to that value. Meaning, it is not bound to the value of variable a. If the variable a later points to a new value, it would not change where the variable b points to, which is the string Dog.
A diagram below to clarify:

This is also the reason why we actually don’t pass variables into functions. We first look up the value the variable points to (is wired to), and that value gets passed into the function (gets used as the argument for the function).
The right side of an assignment is an expression.
Primitive values in JavaScript are immutable. A variable may be reassigned, but its existing value can not change (be mutated) like objects, arrays and functions. There are 7 primitive data types.
JavaScript is a garbage-collected language. We can create objects in memory, but not destroy them. The memory management of JavaScript is performed automatically and is something we don’t have control over as developers.
All primitive values already exist, when we assign a variable to a primitive value, we summon that value. Objects and functions, on the other hand, allow us to generate new values. This is an important point, because objects may look like other objects, functions may look like other functions, but in memory compared to primitive values, they are completely different values.
console.log(2 === 2) // true
console.log({} === {}) // false
In the code example above, 2 strict equals 2 is true, because they point to the same value in memory. Two objects aren't strictly equal to true, even if they look the same to 100%, because they don't point to the same value in memory. In memory, both objects are completely different values.
const adam = {
family: {
alice: {
age: 2
}
}
}
In the code sample above, the nested object properties actually point to other objects, and objects are never really nested.
A diagram below to clarify:

As you can see, the properties and variables are in the end wires that point to values. You can't really nest objects nor point a variable to another variable, in the end, it is always a value.