惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
J
Java Code Geeks
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
IT之家
IT之家
博客园_首页
B
Blog RSS Feed
Google DeepMind News
Google DeepMind News
B
Blog
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
博客园 - 聂微东
腾讯CDC
A
About on SuperTechFans

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
3 Basic JavaScript concepts to start your React Journey: ...
Vignesh · 2026-06-15 · via DEV Community

As the title suggests, we're going to look at three fundamental JavaScript concepts that will help you start your React learning journey. These aren't the only concepts you'll need to learn but understanding them will make learning React much easier.

React is powerful and can be utilized to its full potential when we have concrete understanding of JavaScript. In this part of series, the first three concepts will be

  • Destructuring
  • Speard
  • Template literals

Destructuring:

Destructuring in JavaScript lets you unpack values from array or properties from objects and assign them to individual variables.
Destructuring can also work with any iterable value but I will be focusing on Array and object.

Array destructuring:

const arr = ['red','blue','orange'];

const [c1,c2,c3] = arr;

console.log(c1);

In the example above the list of three colors are destructured into three different variables.
output: red.

const [c1,c2,c3] = arr;

The code above assigns the first three values of the array to separate variables. You can choose how many values you want to extract, and you can even skip values if needed.

const [first, , third] = arr;

Here the second value is skipped.

But what if we want to only take first value and rest to another list. We can achieve that by REST operator.

const arr = ['red','blue','orange'];
const [c1,...c2] = arr;

console.log(c2);

Here any number of values that present inside the array after the first value will be assigned into the c2 variable as new array.
output: ['blue','orange']

Where do we use this in react, Array destructing is used in react hooks.

const [value,setValue] = useState('');

The usesate hook returns an array which contains value and setter function for the to be set.
Array destructing are common in react hooks. Understanding them is important when working with customs hooks.

Object destructuring:

When destructuring objects, we extract values using their property names. The variable names must match the property names. And curly brackets are used instead of square ones.

const person = {name:'Roy',age:28};
const {name, age} = person;

console.log(name, age);

output: Roy 28

When working with multiply objects that contains same property names, destructuring those objects cause error as we use the property names to destructure them. Here renaming or aliasing can help.

const product = {id:1,name:"Bread"};

const {id:productId,name:productName} = product;

console.log(productId, productName);

output: 1 Bread

The rest operator also works with objects same as array. It collects all remaining properties into a new object.

When is object destructing used in react. In react props (properties) are passed from parent to child components. the props we pass in parent are received in child as a whole object. In child component, the props can be destructed and utilised inside the component.

Speard:

const arr = ['car','bike'];
const vehicle = [...arr, 'truck'];

console.log(vehicle);

output: [ 'car', 'bike', 'truck' ]
Speard operator is used to speard (take values out) and place it in new Array. This operation do not affect (mutate) the original array in any way.
speard is broadly used to take shallow copy of an array or object. In the above example an array is speard and new array is created with adding new value truck.

speard in objects

const obj = {name:'roy', age:28};
const obj2 = {id:1, ...obj,};

console.log(obj2);

output:{ id: 1, name: 'roy', age: 28 }

Speard in object works same as in arrays. But in objects, the properties can be edited with new values. this is very useful in react when working with state values containing object.

const obj = {name:'roy', age:28};
const obj2 = {id:1, ...obj, age:35};

console.log(obj2);

output: { id: 1, name: 'roy', age: 35 }. Age value is updated.

Not only adding or overriding property values but merging of two array or objects can also be done.
const colors = {...lightColors, ...darkColors}. results in a single object containing both the objects.

In react, speard is widely used to copying one array or object to new one. Mutating the same array or object may cause errors or confuse react and introduce bugs.

| Both rest and speard used ... - know the different and use accordingly.

Template literals:

Template literals (template strings) are strings enclosed by backticks
instead of single (') or double (") quotes.

const name = "John";

console.log(`Hello ${name}`);

output: Hello John

why use template literals, instead of +. like below.

const name = "John";
const age = 25;

const msg = "My name is " + name + " and I am " + age + " years old.";

but in template literals

const msg = `My name is ${name} and I am ${age} years old.`;

Template literals are introduced in ES6 (JS 2015 release), with bunch of other features like arrow functions. And it is easier to use template literals in situation like above.

In react, Template literals are used everywhere because React often needs to build strings dynamically from state, props, and variables. And used inside different elements and even in dynamically add class names to html elements like example below.

function Button({ isActive }) {
  return (
    <button
      className={`btn ${isActive ? "active" : ""}`}
    >
      Click Me
    </button>
  );
}

active class is added to button element conditionally.

In this part 1, we looked at only three concepts but many more concepts from JavaScript are broadly used in React. In the end React is just a JavaScript Library.