DEV Community

Bipon Biswas
Bipon Biswas

Posted on

1

Rest Operator in Javascript

যখন এটা ফাঙ্কশন আরগুমেন্ট (Function Argument) এর মধ্যে ব্যবহার করা হবে তখন এটাকে রেস্ট অপারেটর (Rest Operator) বলা হবে ।

যেমন আমি একটা Function ধরে নিলাম ।

const numbers = (...args) => {

};
Enter fullscreen mode Exit fullscreen mode

যদি আমরা Function এর Argument এর মধ্যে ...args করে লিখি তাহলে এটা Unlimited নাম্বার Argument ডাটা রিছিভ করতে পারে ।

তাহলে আমি যখন Function টা কল করবো তখন অনেকগুলো ১,২,৩,৪,৫ নাম্বার দিয়ে কল করলাম ।

numbers(1, 2, 3, 4, 5);

এখন যদি আমরা এই টাকে দেখতে চাই তাহলে -

const numbers = (...args) => {
  console.log(args);
};
Enter fullscreen mode Exit fullscreen mode

Output: [1, 2, 3, 4, 5]

তারমানে আমি parameter হিসাবে যা পাঠাব টা Array আকারে দেখাবে ।
যেহেতু Array আকারে পাচ্ছি তাহলে এখানে Array এর বিভিন্ন মেথড ব্যবহার করতে পারব ।

Source

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more