Getting length of array returned by a regex?
Hello I am practicing JavaScript and I got in a little problem I canât figure out: Iâm trying to get an array containing all occurrences from a regex in JavaScript and Iâm doing something like this: var str = âThis IS a trYâ; var pattern = /[A-Z]/g; var matches = str.match(pattern); And till now it all works because if I do console.log(matches) it will print out something like this ( T, I, S, Y ) Just like it usually do with arrays, so I am assuming that in this case the match method is returning an array with all occurrences from the regex. The problem is that I would like to get the length of this array, but if I do matches.length as we usually do for an array I will get an error... so should I assume that the method is not actually returning an array? Is there a better way to do what Iâm trying to do?