Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three dots in javascript code [closed]

I just found this bit of code within a .js file which is online, live and functional:

if (p.length > 0) { l() ...try { I = $.parseJSON(k.getData()); /*and so on until*/ } catch { /*more code*/ }

I have never seen three dots as a code element before (I double-checked there weren't quotes anywhere around), but this seems to work: there is no error log in the console. What exactly does this syntax achieve?

like image 715
Armatus Avatar asked Sep 05 '13 01:09

Armatus


2 Answers

Just for completeness, ES6 will likely have "..." in it, for "rest" parameters (a replacement for using arguments):

function g(i, j, ...r)

But that is not what this code is doing.

http://espadrine.github.io/New-In-A-Spec/es6/

like image 197
Brian Genisio Avatar answered Nov 07 '22 23:11

Brian Genisio


Credits to Tim Goodman: Firebug truncated the js file for some reason and randomly inserted "..." instead.

like image 2
Armatus Avatar answered Nov 08 '22 00:11

Armatus