Q:

take rgb string convert to decimal

i have string 'rgb(255,0,0)' and need to get array of decimals.
The following snippet seems to give me the desired results. Any suggestions, concerns, better ways?
var arrRGB = pagedefault.nodelist.style.color.match(/\d+/g); //gives me ["255","0","0"]
arrRGB[0] = Number(arrRGB[0]) / 255;
arrRGB[1] = Number(arrRGB[1]) / 255;
arrRGB[2] = Number(arrRGB[2]) / 255;

A:

'rgb(255,0,0)'.match(/\d+/g).map(Number) // ==> [255, 0, 0]

works if you have a map implemenation.

A:

I would wrap part of the logic in a for loop:
var arrRGB = pagedefault.nodelist.style.color.match(/\d+/g);
for (var i = 0; i < arrRGB.length; i++) {  
    arrRGB[i] = Number(arrRGB[i]) / 255;
}

Otherwise, this looks fine.

