pocket pocket - 2 months ago 5x
Javascript Question

", match" syntax Javascript

While reading through an implementation of a lightweight router I ran into a syntax form I haven't yet learned or seen yet.

var re = /{{.+}}/g, match;

I understand the regular expression, but can't seem to find any documentation on the comma then "match" syntax. I've attempted to use this syntax like so:

var test = "hello", match;

which also seems to work. Match is not that is declared within the code. Could anyone clarify or link to any documentation on the use of the comma operator in a variable assignment? I found this link on the comma operator: MDN on Comma Operator. But I'm still struggling to understand what's going on here.


This is declaring 2 variables, one is called re the other is called match and has a value of undefined