Prototypal inheritance basics in Javascript

Objects in JavaScript are dictionaries. Each of them has a magic __proto__ field that can point to any object which will be the prototype of the first one. When you look up a field on the object using either obj.field or obj["field"] syntax (they are different way of doing the same thing), and the field is not present in the object, the JS runtime looks for the same field on the prototype. If the field still can't be found, the property is looked up on the prototype of the prototype, etc...
const a = { x: 5 };

Writing Custom Callback for ajax

In this post, I will share how could you use callbacks to write efficient and maintainable ajax using callbacks. Promises can also be use but here i will discuss it with callbacks.
The definition of callback is
A reference to executable code, or a piece of executable code, that is passed as an argument to other code. 
Let's see an example code of custom callback,
function test(param1, param2, callback) {
    alert('Started function.\n\nIt has: ' + param1 + ', ' + param2);
    callback();
}
test('foo', 'bar', function() {
    alert('Finished function.');
});

Pages