Author -  Sai gowtham

How to use the Rest Parameters (...) in JavaScript

In JavaScript, the rest parameters (…) help us to represent the infinite number of function arguments as an array.


function sum(a,b,...remaining){

     console.log(a);

     console.log(b);

     console.log(remaining)
}

console.log(sum(1,2,3,4,5,6,7))

//a -> 1

//b - > 2

//remaining - > [3,4,5,6,7]

In the above code sum function accepts three arguments a, b and remaining. where the first two arguments values are 1,2 everything we passed after the first two arguments are represented as an array.

function sortNumbers(...numbers){
    return numbers.sort((a,b)=>a-b)
}

console.log(sortNumbers(4,5,6,2,1,7,3))

//Output--> [1,2,3,4,5,6,7]

If we prefix any parameter with (…) that parameter can accept unlimited arguments and represent it as an array. Like in the above example we prefixed ...numbers so that it can accept many arguments.

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY