comma operator in javascript different use cases with examples

Опубликовано: 02 Октябрь 2024
на канале: Tech Nursery
47
0

if you want to know what is comma operator and its advantages in javascript,then this video is for you .Here we discuss about comma operator different use cases in javascript with examples

comma operator evaluates from left to right, and returns the value of the right expression

So keep the above sentence in mind,then you can easily understand the use cases and advantages of comma operators in javascript

//comma operator evaluates from left to right, and returns the value of the right expression


let x = 100;
let y=(x++,x,x+1);
console.log(y) //102

let num = (100, 100 + 200);
console.log(num); //300

let result = (1,2,3,4,5)
console.log(result) //5