A practical introduction to git basic concepts.

Image for post
Image for post
Photo by Yancy Min on Unsplash

Git is a DVCS: Distributed Version Control System.

Basically, with git you and your team can cooperate to create, modify, extend, maintain code working in parallel on the same codebase, without worrying about “breaking” the code.

When you want to develop a project using git you create a repository — a directory containing your project’s code and a .git subdirectory used by git itself to keep track of everything.

Note: repositories are often called repo for brevity.

The command to initialize a folder is:

git init 
git init <directory_name>

Keep Track Of a File

Git doesn’t automatically keep track of files in the repo, you have to tell him that you want it. …

Like functions, but shorter…more or less. Let’s find out!

Image for post
Image for post
Photo by Steinar Engeland on Unsplash

Arrow functions are those weird functions using a funny syntax mimicking how humans write or draw them on paper:

(param1, param2) => { /* do something */ }

The answer is yes, they’re mostly a shorter way to write functions, but there are some little differences.

Arrow functions are anonymous

The first thing you may note from the above snippet is that arrow functions haven’t got a name — they’re anonymous.

For instance, you cannot write something like this:

functionName(param) => { /* do smth */ }

A brief and practical introduction to their functioning and use

Image for post
Image for post
Photo by Oskar Yildiz on Unsplash

What are JavaScript closures?

MDN web docs give this great definition of what a closure is:

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

A practical example

This example comes from this series about closures that I’ve made, but with a simpler syntax to be more beginner-friendly, and with some improvements, because in series you must be short:

A SIR model simulator using p5.js library

Covid-19 spread map
Covid-19 spread map
Photo by Giacomo Carra on Unsplash

Being forced at home due to Italy’s lockdown, I had to find something to do, then finally someone gave me the idea: why don’t you create a SIR Model simulator? He was suggesting to create something like the simulations you can find here. The idea was interesting so I decided to give it a try (here’s the final result, and here’s the code).


Lorenzo Felletti

Computer Engineering student at the University of Bologna

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store