Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the double-dot operator (..) in Javascript?

I'm doing some work with the Parser API in Spidermonkey. The docs show that there's a binary operator ... Anybody have any idea what this is/does? I'd love to know. I've never seen it before. If I were forced to guess, I'd have to say it's something with E4X, but that's only because I know nothing about E4X.

like image 976
mattbasta Avatar asked Nov 18 '10 02:11

mattbasta


People also ask

What is dot operator in JavaScript?

The dot (.) is simply an operator that sits between its operands, just like + and -. By convention, the variables stored in an object that we access via the dot operator are generically called properties. Properties that happen to be functions are called methods.

What are 3 dots in JavaScript?

Rest operator. When used within the signature of a function, where the function's arguments should be, either replacing the arguments completely or alongside the function's arguments, the three dots are also called the rest operator.

What do 3 dots mean in Typescript?

The three dots are known as the spread operator from Typescript (also from ES7). The spread operator return all elements of an array. Like you would write each element separately: let myArr = [1, 2, 3]; return [1, 2, 3]; //is the same as: return [...myArr];

What is dot dot dot in Typescript?

Three dots ... is called spread operator in Javascript and Typescript. This is useful when we want to. create a copy of a object. destruct an array and pass them to parameters.


1 Answers

Not to be confused with the decimal point and dot:

var val= 1000..toExponential() 
like image 73
kennebec Avatar answered Sep 19 '22 18:09

kennebec