React Component Nesting and Reusability Explained – A Beginner's Guide 2026

Image
1. Introduction to React Component Nesting and Reusability React JS is a popular JavaScript library used to create interactive and user-friendly web applications. One of the most useful concepts in React development is component-based architecture. Instead of writing an entire website inside one large file, developers divide the user interface into smaller and manageable parts called components. Two important concepts in this approach are component nesting and component reusability. Component nesting means placing one React component inside another component to build a complete user interface. For example, a website page may contain a header, navigation bar, sidebar, content section, and footer. Each section can be developed as a separate component and combined inside a main component. Component reusability means creating a component once and using it multiple times in different parts of an application. For example, the same button, product card, or navigation menu can be reused withou...

JavaScript while loop (with example)

  JavaScript while loop  Program

JavaScript while loop (with example)




While statement create a loop ()is executed while a condition is true .

 while loop run the condition is the true.

In JavaScript, a while loop is used to carry out repetitive operations by running a block of code repeatedly as long as a given condition is met.

 The code inside the loop is run once the loop has evaluated the condition and found that it is true.

 The condition is verified once again following each execution of the loop's code block. 

The loop continues in this manner until the condition evaluates to false, at which time it breaks and the code that comes after the loop executes.

Syntax :- 

while (condition check)


{


code executed


}


Code Explain :-

     ஃ While loop  use the codition inside ( ).

    ஃ  while loop  condition  TRUE then code { } executed.

    ஃ while loop code evaluate again.

    ஃ This condition  FALSE then loop terminates.

FlowChart             

while loop Example

Q. Display Number of 1 to 15 


let num =1;
while (num <=15)
{
  console.log(num);
  num++;
}

Explain :-


 num initialized to 1
 while loop continues
   count is less than equal(num<=15)
   console.log(num)
   After num ++ increment value 1 each iteration.

Output :- 


2] while loop Example

Q. Display Number from 1 to 4


let x=1;
while(x<5)
{
  console.log(x);
  x+=1;
}

Explain :-


  initialized variable 1

while loop continues count  less  (x<5)
console.log(x)
  x is increment by 1

Output :-


3]while loop Example

count number in while loop


let count_number=1;
while(count_number<5)
{
    console.log(count_number);
    count_number++;
}

1]  let count_number = 1 
2] count_number<5 loop runs while loop.
3] less than 5 count_number = 1 
4] console,log(count_number = 1 )
5] print current value and count_number ++ increment value by 1 each time.
6] count_number  reaches 5 value the condition false 
7] than loop exits

Output :-



Related Post :-

Comments

Popular posts from this blog

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples

Learn CSS text-decoration-color Property in Simple Words with Examples