JS Punctuator stats


Super random :) But here's some stats on encountered punctuators in JS in a 8mb file of concatenated scripts (various libraries, large website codes, etc). Results are probably skewed one way or the other, but you should get a general idea. I intend to provide slightly lesser skewed stats in the future, but not sure when I will have them.

If you're wondering why these stats are skewed, consider the difference in whitespace count when parsing a regular script versus a minified script. You'll find far more spaces in development scripts. Likewise, build scripts and coding styles tend to use the same patterns and therefor the same kind of operators (single quotes vs double quotes, less than vs greater than, increment vs decrement, etc). So if we parse a handful of libraries, especially when minified, we'll end up with certain patterns that skew these stats.

Counts of more than 1000 are rounded. These are the stats for the approximately 1.4M punctuators found in the 8mb test file:


251400x: .
140200x: ;
197800x: (
197800x: )
113200x: =
134500x: ,
82500x: {
82500x: }
49600x: :
43700x: [
43700x: ]
16200x: +
10200x: &&
9400x: !
8800x: ==
8700x: ||
6700x: ?
6400x: -
5700x: ++
4800x: <
4300x: *
3500x: !=
2800x: +=
1900x: >
1700x: ===
1100x: !==
1000x: /
941x: >=
770x: &
501x: <=
581x: --
488x: -=
306x: >>
300x: %
275x: |
260x: <<
116x: ^
112x: |=
111x: *=
56x: ~
55x: /=
44x: &=
31x: >>>
14x: >>=
14x: ^=
13x: %=
1x: <<=
0x: >>>=

Anything surprising? For me it's the colon. I didn't realize it was used so often. Switch cases (2k), labels (44x), ternary expressions (6.7k), but mainly object literals (40.6k).

Ok, enough geeking out, back to work!