Flashing colors 'UnityEngine.Component.renderer' is obsolete.

Hi, imported my old flashing colors script however seems to be obsolete, not sure were to put the GetComponent() (with my rigidbody errors i just had to insert a var declairing ridgid body as getcomponent, however Renderer didnt work that way.
JS:

#pragma strict

var colors = new Color[2];


function Update () 
{ 
renderer.material.color = colors[0]; yield WaitForSeconds(.5); renderer.material.color = colors[1]; 
}

Renderer renderer = GetComponent(Renderer);

renderer.material.color = colors[0]; yield WaitForSeconds(.5); renderer.material.color = colors[1];