Can't understand generic getComponent for Js

What’s the deal? I looked over the other posts regarding the generic versions of getcomps but I still don’t understand exactly how to use it. I’m using js.

I am curious because I read somewhere that generic is better for performance? If so, how so?

I am practicing with this but I keep getting errors

var script : behaviorScript;
script = GetComponent.<behaviorScript>(); 
headBone = script.headBn;

Error: behaviorScript is inaccessible due to its protection level.

what’s wrong with it?

My goal is to not have to type out ‘GetComponent’ every time I need something from another script. I would like to be able to just say 'script.Blah()'. I use getcomponent quite a bit and in update, so if I save on performance I really want to learn this.


I found out what the problem was- I had the variable I wanted to access marked as private. When I declared it public, it worked. I would still like to know if this method is better for the engine, if someone could please explain?