JS, Git & NoSQL

Diunugala M W
4 min readMar 17, 2022

--

What is “this” in JavaScript?

In programming languages, we can find “this” keyword in many. But it differs on language to another. When it comes to Java, “this” keyword refers to the object context. Since we talk about the JavaScript, let’s look at “this” keyword in JavaScript.

“this” keyword in JavaScript is referring the context from where the function is being executed from. When it comes to the circumstances like, the reference function is a regular function, “this” keyword is referring to the window object (global object).

Let’s see some coding stuff, So that you will understand the content :)

this.type = "Sedan"

function printVehicleType(){
console.log(this.type);
}

printVehicleType();

const Jeep = {
type : "SUV",
printVehicleType : printVehicleType,
}

Jeep.printVehicleType();

What is “Strict Notation” in JavaScript?

Actually Strict Notations is a restricted mode in JavaScript and the purpose of that is to make it easier to write secure JavaScript.

What is “Closure” in JavaScript?

Closure is allowing us to encapsulate the properties or hide them from the outer world. We can understand it as a function that returns inside a function.

function func1(var1){
return function(var2){
return var1 + " and " + var2;
};
}

const secondFuncPointer = func1(5);
console.log(secondFuncPointer(3))

According to the above example, secondFuncPointer only gets what func1 is returning. that mean secondFuncPointer is pointing to the

“retuen var1 + “ and ” + var2;” line.

But the values that passing through secondFuncPointer, will pass the parameters as func1.

What is “Callback and Promises” in JavaScript?

JavaScript is asynchronous. All I/O operations in JavaScript is implemented to be asynchronous by nature. Reason for this is JavaScript being a single threaded language if an I/O operations holds the thread till it get completed JavaScript won’t perform well as a programming language.

But asynchronous operation introduce difficulty when we need to do synchronous processing using data and it is solved by using callbacks and promises.

Callback is a function that is being passed to an async task and on completion the function will be executed and Promise is an object that is being returned from async tasks. Promise have properties to deal with async operations synchronously.

What is “Version Controlling”?

It is a system that managing changes to a source and those changes are identified using a revision number. Each revision has its timestamp and the person who done the change. Those revisions can be restored, compared and merged.

Why?

VS ease backups and centralized source code repository, easy collaborative development.

Terminology

  • Repository — Central location where all the files are being kept. Usually a directory with set of files.
  • Trunk — Also referred to as master branch. This is where the most stable code is being placed which is referred as the production code.
  • Stage — Mark files for tracking changes.
  • Commit — Create a snapshot of the changes being made to the files.
  • Branch — Copy of the master branch taken at a given point. All the feature developments and bug fixes will be done in a branch. Usually it is allowed to have multiple branches at the same time.
  • Checkout — Mark/unlock file for changing.
  • Merge — Combining branches together to update the master branch.
  • Merge conflict — Merge conflicts occur when merging a file which has been changed in two separate branches or places. Changes that interfere other changes.

What are the Best Practices?

Use a source control system.

Always make sure to have the latest version of the file.

In distributed source control system advice is to get the latest source code at least start of the day.

Checkout only what you need.

**Git is most popular version control system.**

What is “NoSQL”?

Those are Non relational, schema free, distributed databases. When it compared to SQL databases, replication process is very easy. And mostly open source.

Why?

Remove the burden of data structures mismatch between application in-memory and relational databases.

Integrate databases using services. (ElasticSearch).

Relational databases not designed to run efficiently on clusters.

Aggregate oriented databases, are easier to manage inside clusters and based on the domain driven design. (Order details inside the order).

  • *MongoDB is a simple example for NoSQL. It has strong query capabilities with aggregation using JavaScript. It has an inbuilt file storage called Grid File System.**

What is “CAP Theorem”?

In theoretical computer science, the CAP theorem, also named Brewer’s theorem after computer scientist Eric Brewer, states that any distributed data store can only provide two of the following three guarantees: Consistency Every read receives the most recent write or an error.

That’s all folks. Hope you learn something :)

--

--