Web development and more
Photo by Joshua Aragon on Unsplash

What is callback hell and why does it happen?

callback hell

Callback hell is a common problem when coding in Asynchronous JavaScript. In a asynchronous function, we use callbacks to request and retrive value from other functions. The operation would be more complicated if we need more callbacks on the line. For example, you call the resource and wait for the…

Photo by Andrew Petrov on Unsplash

What is a JavaScript Promise?

‘A Promise is a proxy for a value not necessarily known when the promise is created.’ — MDN

A Promise is a javaScript mechanism that can be used for asynchronous programming. It contains resolve and rejects functions. JS promise will process resolve function as the condition we have settled, or…

Photo by Pavan Trikutam on Unsplash

A callback function, namely, is a function that calls back with another function.
The common example is addEventListener:

target.addEventListener(type, listener); 
//the listener is always a function

Everytime when the target event has been triggered(listened), it run the listener function.

This tells about what asynchronous programming is- the program doesn’t react…

Photo by Thomas Kelley on Unsplash

Inheritance is a code-reused mechanism in object-oriented programming. You can simply create a new class from an existed class.

1. Defining a Teacher() constructor function

Task:
We create a class called Person, and then derive an inherited class(we call it ‘subclass’), Teacher.

Useful methods:

function Person(name, age, gender, habit) {
this.name = name;
this.age = age;
this.gender = gender;
this.habit = habit;
}
Person.prototype.greeting = function() {
console.log('Hi!' + ' my…

Dusing Chang

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