Posts

React Interview Questions - Controlled vs Uncontrolled

React Interview Questions - Controlled vs Uncontrolled React Interview Questions Controlled vs Uncontrolled Components in React 1. What is a Controlled Component in React? A controlled component is a form element whose value is controlled by React state. Example: const [name,setName] = useState(""); <input value={name} onChange={(e)=>setName(e.target.value)} /> 2. What is an Uncontrolled Component in React? An uncontrolled component stores form data in the DOM instead of React state. Example: const inputRef = useRef(); <input ref={inputRef} /> 3. What is the difference between Controlled and Uncontrolled components? Controlled components use React state while uncontrolled components use DOM references. Controlled components are easier for validation and form handling. 4. When should you use Controlled Components? Use controlled components when you need validation, dynamic UI updates, or form control logic. 5. When...

gg

Understanding React Auth & Hooks 🛠 React: useState vs useRef vs useMemo + Login Explained 1️⃣ useState vs useRef useState is for updating and re-rendering the component. useRef stores a value across renders without causing a re-render. const [count, setCount] = useState(0); const countRef = useRef(0); 2️⃣ useRef vs useMemo useRef stores values or DOM nodes. useMemo is for performance, caching results of calculations. const value = useMemo(() => expensiveCalc(num), [num]); 3️⃣ How Login Works in React User fills login form React sends data to backend Backend validates and sends token React stores token Future requests include token 4️⃣ Where Token is Stored Tokens are stored in: localStorage sessionStorage Cookies (more secure) 5️⃣ Who Generates the Token? The backend (e.g. Express, Django) generates the token and returns it to React. React stores and uses it for authentication.

What is the closure function in Javascrpt(javascrpt)

JavaScript Closures Quiz JavaScript Closures Quiz 1. What will be the output of the following code? function outerFunction() { let outerVar = "I am from the outer function"; function innerFunction() { console.log(outerVar); } return innerFunction; } const closureExample = outerFunction(); closureExample(); A) I am from the outer function B) undefined C) ReferenceError 2. What is a closure in JavaScript? A) A function that is called without arguments B) A function that returns another function and remembers its lexical scope C) A function that only runs once 3. Which of the following is an advantage of using closures in JavaScript? ...

Quston 1

C# Polymorphism and Method Hiding Quiz C# Polymorphism and Method Hiding Quiz 1. What will the following code output? class Grandfather { public virtual void Display() { Console.WriteLine("Grandfather's display method."); } } class Father : Grandfather { public override void Display() { Console.WriteLine("Father's display method."); } } class Child : Father { public new void Display() { Console.WriteLine("Child's display method."); } } class Program { static void Main() { Grandfather person = new Child(); person.Display(); } } A) Grandfather's display method. ...