>>>>>>> Fragment[TBD] <<<<<<<<
Difference between JS vs JSX:
JS(JavaScript):
What it is: A standard programming language used for web development.
Used for: Logic, data handling, functions, event handling, etc.
Syntax: Pure JavaScript syntax (e.g., if, for, function, etc.).
Example:
const name = "Priya";
console.log("Hello " + name);
JSX (JavaScript XML):
What it is: A syntax extension for JavaScript used in React.
Used for: Writing HTML-like code inside JavaScript.
Looks like: HTML but works inside JavaScript.
Example:
const element = <h1>Hello, Priya!</h1>;
Key Differences:
In React, you use JSX inside JS:
function App() {
const name = "Priya";
return <h1>Hello, {name}</h1>; // JSX inside JS
}
JSX makes writing React components easier and more readable.
Library:
- A library is like a toolbox.
- React is a library that helps you build user interfaces (UIs).
- You decide how to use the tools (how to organize your app, when to call functions).
- React doesn’t control your whole app – it just helps you build parts of it, like buttons, forms, etc.
Framework:
- A framework is like a ready-made structure or a blueprint for building an app.
- It controls the flow of your app and tells you where to put your code.
- You build inside the framework, following its rules and structure.
In Programming:
Framework = “I will call your code at the right time.”
Components:
In React, a component is like a reusable building block of your user interface.
Example:
function Welcome() {
return <h1>Hello, welcome to my site!</h1>;
}
Component have two types:
- Class components
- Functional components
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.