Stellar Code

Full-stack Web Development with JavaScript (MERN stack)

JavaScript First Principles: #0. Introduction


This post will be the first of many in a series of writing where I will be exploring JavaScript from first principles. What exactly do I mean by ‘First Principles’ and why is Elon musk the featured image? First principles is a term used in Physics, but of which I learned from Elon Musk (one of the most successful tech entrepreneurs today). Here what he has to say:

“I think it’s important to reason from first principles rather than by analogy. With first principles you boil things down to the most fundamental truths… and then reason up from there” – Elon Musk.


In applying first principle thinking to JavaScript, I simply imply understanding the core foundations of the language. With the torrent of new frameworks been developed every other year, it’s great for a developer to understand the core concepts of JavaScript. When you master the first principles, every hot new framework is just more JavaScript to you.

In this post, I will explain the ABC of programming and how it really works. Before one learns to read and write in JavaScript, he needs to become familiar with some concepts in programming. The concepts I will this post will feature are: Scripting and Object Models.



First of all, what is a script? A Script is a series of instructions that a computer can follow to achieve a goal. A script can be compared to a cooking recipe. By following the instructions in a recipe, one-by-one and in the order set out, anyone can create a dish that they have never made before.

To write a script, you need to first state the goal and then list the tasks that need to be completed in order to achieve it. No matter how complicated a script looks, it’s just a short series of instructions each of which is performed in order to solve the problem at hand. It is worth noting that unlike humans, computers need to follow detailed instructions every time it performs a task as if it were its first time.

After a goal has been defined, the script is designed by breaking the goal into specific steps that need to be performed (using tools like flowchart) and each step is finally written in code. As a developer, it pays to spend time designing your script before you start writing it.

Baking a cake step-by-step
Baking a cake step-by-step




How do computers understand the world around them? It’s all about Objects. Computers model real world stuff using data. This is how computers understand the world around them. A computer has no predefined concept of what a car or a hotel is and does not know what they are used for. It cannot know your favorite brand of car or what rating your hotel is. However, apps like a car racing game or hotel booking app work by the data a programmer uses to create a different kind of model for the computer. In programming, each physical thing in the world can be represented as an object.

A car and a hotel
Real life objects


Each object usually has its own: Properties, Events and Methods.

Source: Jon Duckett


  • Properties:

This are the characteristics that a physical thing can have. Each individual object property has a name and value that gives information about it. For instance, all cars have a property name of color and the value that distinguishes them is a value of grey or maroon

  • Events:

In the real world, people interact with objects. These interactions will change the value of the properties in this object. For instance, when a car’s accelerate pedal is pressed down, its speed property changes. Similarly, programs are designed to do this differently when a user interacts with them. An example is how in a car video game, holding the accelerate button increases the speed property of the car to a value of 75km/h.

  • Methods:

This is triggered by events. They update an object’s properties through a series of processes. In programming there are functions ending with double-brackets (). For instance, a method to book a hotel could be called makeBooking() {...}; inside of which steps are defined to make a booking, thereby changing a hotel’s bookings property name to a value of maybe 22 if there were 21 reservations previously.


Subsequent posts will explore more of JavaScript.

Also published on Medium.

Emmanuel Yusufu

Web Developer. Learning enthusiast.