在下面的代码中,TypeError: string is not a function
第 30 行var myColour = new colour(255,255,255);
被抛出。任何人都可以看到代码有什么问题。非常感谢。
var bodies = [];
var orbits = [];
var colours = [
new colour(45, 45, 45),
new colour(255, 0, 0),
new colour(0, 157, 255),
new colour(77, 250, 81),
new colour(255, 247, 0)
];
function colour(red, green, blue)
{
this.red = red;
this.green = green;
this.blue = blue;
};
window.onload = function() {
var c = document.getElementById("theCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
for (var colour in colours){
console.log(colour.red);
console.log(colour.green);
console.log(colour.blue);
};
var myColour = new colour(255,255,255);
console.log(myColour.red);
console.log(myColour.green);
console.log(myColour.blue);
};