It may be useful having about 150 named colours to draw with but in fact there are over 16 million colours that can be displayed (16,777,216 = 2563) and sometimes we want to select colours more precisely from that range.
Displayed colours are made up from 3 components, red, green and blue (RGB), to match approximately the pigments in our eyes. Javascript uses 1 byte for each of those colours. A byte can hold 256 different numbers, from 0 to 255. There are several ways to specify how much of each colour we want. A simple way is rgb(255, 255, 0)
which would produce bright yellow: equal amounts of red and green but no blue.
It is important to realise that the colour specification is really part of CSS rather than Javascript. This means that the specification must be given as a text string, in quotes, in our programs. Thus:
g2.fillStyle = "rgb(255, 255, 0)";
For those who know that 1 byte can be represented as 2 hexadecimal digits there is another way to write that:
g2.fillStyle = "#ffff00";
And because each of the digits is repeated that may be shortened further to
g2.fillStyle = "#ff0";