Conditional Rendering in React Complete Guide with Examples 2026

Image
  Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.

Javascript variable with example

Javascript  variable with example

 

what is a variable  JavaScript

 1] JavaScript variables are containers for storing information.

2]   JavaScript store data value.

JavaScript Variable 

1] var    

2] let

3] const


1] var   

   1]  JavaScript variables must identified with unique names.

  2]  Unique names call identifier.

 3]  identifier descriptive name is the (total volume,  age, sum).

 4]   Creating a variable  in JavaScript is declaring the variable.

Example :-

JavaScript Code :


    var a= 10;
    var b=20;
    var c= a+b;
    document.write(c);

Output :

variable javascript

2] let :-

 1] let statement separate the variables by comma.

2]  let can not be redeclared.
 

Example :-
JavaScript Code :


{
    let value = 50;

document.write("Inside the function
value = " + value);  
}
document.write("<br> Outside the function value = " + value);  

Output

let variable javascript


3] const :-

  1] JavaScript  const is keyword use declare a variable .
  2]  const variable cannot be reassigned a new value.
  3]  const keyword declare a variable do not change the value.
  4] const variable creates only reference value.

Example :-
JavaScript Code :

const x = 90;  
     document.write("const variable value x = " + x);  

OutPut :-


Related Post :-

how to create simple login form use

html aside tag

php program to print alphabet pattern S

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example