Posts

Showing posts with the label Apply

SOLID / DRY principles

In software development, Object-Oriented Design plays a crucial role when it comes to writing flexible, scalable, maintainable, and reusable code. There are so many benefits of using OOD but every developer should also have the knowledge of the SOLID principle for good object-oriented design in programming. The SOLID principles are designed to help developers design robust, maintainable applications. The five SOLID principles are: Single-responsibility principle - Function and classes should have one job. Open–closed principle - Classes and functions should be open for  extension but not for modification. Liskov substitution principle - Child class can replace parent class Interface segregation principle - This principle is the first principle that applies to Interfaces instead of classes in SOLID and it is similar to the single responsibility principle. It states that “do not force any client to implement an interface which is irrelevant to them“. Here your main goal is ...

Difference between Call, Apply and Bind

In JavaScript, the `call`, `apply`, and `bind` methods are used to manipulate the execution context (the value of `this`) of a function. They allow you to control how a function is invoked and provide arguments to the function. Here's a breakdown of their differences and usage: 1. `call`:    - The `call` method is used to invoke a function with a specified `this` value and individual arguments passed as separate parameters.    - It takes the `this` value as its first argument, followed by the function arguments.    - Example:    function greet(name) {      console.log("Hello, " + name + "!");    }    greet.call(null, "Alice");    // Output: Hello, Alice!    const obj = { name: "Bob" };    greet.call(obj, obj.name);    // Output: Hello, Bob!      In this example, `call` is used to invoke the `greet` function with a specific `this` value (`null` and `obj`, resp...

Popular posts from this blog

Why do we need callbacks

Difference between localStorage and sessionStorage

Scope in javascript