Thursday, November 2, 2023

Backend API interview Question

1) How to improve performance?

2) PATCH  (Partial Update):PUT (Replace or Full Update):

3) Do you know what is Database Indexes ? Database Primary Index have only one / Secondary Index 

4) Concept of middleware in Express.js

    execute code during the request-response cycle. Middleware functions have access to the request object (req), the response object (res), and the next function in the application's request-response cycle. They can perform tasks, modify the request or response objects, and either terminate the cycle or pass control to the next middleware function by invoking the next function. Middleware functions in Express.js can be used for various purposes, such as logging, authentication, handling errors, modifying the request or response, and more.

5) What is the purpose of the async and await keywords in Node.js?

  • Answer: async and await are used to work with Promises in a more synchronous style. The async keyword is used to declare an asynchronous function, and await is used inside an async function to pause execution until the Promise is resolved.

Tuesday, October 31, 2023

React Interview Questions

 What is state in React, and how is it different from props? 

  • State is an object that belongs to a React component and can be used to store and manage data that can change over time. It is mutable and can be changed by the component itself. In contrast,  
  • props are read-only and passed from a parent component to a child component. 

What are React Hooks, and how do they work? 
  • React Hooks are functions that allow functional components to manage state and side effects.
  •  The most common hooks are useState, useEffect, and useContext
  • Hooks enable functional components to have state and lifecycle features that were previously exclusive to class components. 
  • Example const [count, setCount] = useState(0); 
  • useEffect hook can be used in two primary ways: with a dependency array (an array of values) and without a dependency array. 
    • with a dependency array, the effect will run under specific conditions
    • without a dependency array - runs on every render. 

When Use Redux and Context ? 
    Use Redux when: You're working on a large and complex application with extensive state management needs, or when you need to handle complex asynchronous actions, middleware, and a single source of truth. Redux's predictability and mature ecosystem make it a good choice for such scenarios. 

    Use React Context when: You have simpler state management needs, such as sharing data between parent and deeply nested child components. React Context is great for avoiding prop drilling and keeping your component tree clean. 

     

    Friday, August 4, 2023

    SQL Server Express and Port

    set SQL Express with another port, e.g. here 1066
    then you can connect it with localhost, 1066



    Tuesday, April 11, 2023

    Fetching API in parallel

      const [memberResults, cartItemResult] = await Promise.all([

    makeAPIRequest("get", `members/${currentUser.uid}`),
    makeAPIRequest("get", `memberCart/get/cart/items/${currentUser.uid}`),
    ]);

    Thursday, February 23, 2023

    How Access Between Angular

    • From Parent to access child component
      • @ViewChild()
    • Pass Data between child and parent component
      • @Input() 
        • data from parent to child
        • @Input() item = ''; // decorate the property with @Input()
        • Directive From Parent Component
        • <app-item-detail [item]="currentItem"></app-item-detail>
      • @Output()
        • data from child to parent with the help of the event.
        • to raise event must have EventEmitter

    Angular Question

    • Type of Data Binding
      • One Way Binding
        • Interpolation Bnding
          • data move in one direction from components (typescript) to HTML
          • <p>{{ message }}</p> 
        • Property Binding
          • set properites to HTML elements.
          • [value]="user.email" or <img [src]="imageUrl"> 
      • Two Way Binding 
        • component and view are always in sync
        • Changes in user interface to model state.
        • Changes in model state reflect to user interface
        • <input [(ngModel)]="name">
    • Event Binding
      • One Way Binding
      • for event trigger
      • <button (click)="doSomething()">Click me</button> 


    • How does one share data between components in Angular? 
      • Parent to child using @Input decorator 

      • Child to parent using @ViewChild decorator 
      • Child to parent using @Output and EventEmitter 
    • Decorators
      • Design Pattern & function
      • modification to a class, service or filter
      • 4 Types
        • Class Decorators
        • Property Decorators
        • Method Decorators
        • Parameter Decorators
    • Advantages
      • MVC architecture
      • Modules
        • componentes
        • directives
        • pipe
        • services
      • Dependency Injection
        • component dependent on other components can easily worked around
      • Others
        • clean and maintainable code
        • reusable components
        • data binding
        • unit testing
    • Directives
      • attributes allow user write new HTML syntax
      • 3 Types
        • Component Directives
        • Structural Directives
        • Attribute Directives

      • myHighlist is Directives
    • Template
      • HTML View
      • seperate template file such **.html
    • Template Statements
      • properties or methods
      • (click)='addUser()"
      • addUser is template
    • Promises and Observables
      • Promises
        • emit single value at a time
        • Execute immediately after creation and not cancellable
        • Push Errors to child Promises
      • Observables
        • execute when subscribe()
        • emit Mutiple value over a period of time
        • perform forEach, filter and retry
        • Deliver errors to subscribers.
        • When unsubsribe() is called, listener stop receive further values.
    • ObservablePromise
      Declarative: Computation does not start until subscription so that they can be run whenever you need the resultExecute immediately on creation
      Provide multiple values over timeProvide only one
      Subscribe method is used for error handling which makes centralized and predictable error handlingPush errors to the child promises
      Provides chaining and subscription to handle complex applicationsUses only .then() clause
    • Difference AngularJS and Angular
    • AngularJSAngular
      It is based on MVC architectureThis is based on Service/Controller
      It uses JavaScript to build the applicationUses TypeScript to build the application
      Based on controllers conceptThis is a component based UI approach
      No support for mobile platformsFully supports mobile platforms
      Difficult to build SEO friendly applicationEase to build SEO friendly

    Sunday, February 19, 2023

    Dependency Injection 2

    What is Dependency Injection

    • Produce a loosely coupled code
    • Any change in the class without affecting other object.
    • Type of DI
      • Constructor Injection
        • parameter to inject dependencies in a class
        • One parameterized constructor but no default constructor and you need to pass specified values to the constructor


      • Setter Injection
        • through properties of a class


      • Interface-based injection
        • through method


    • Advantage
      • Maintainability
        • maintain code structure, single principle
      • Flexibility
        • loosely coupled code, flexible to use different ways.
      • Testability
        • easy to do unit testing
      • Readability
        • Logic in constructor.