As I can assign a script to an object using JavaScript?

As I can assign a script to an object using JavaScript?

I have a script called "MyScript". And i have an object called "MyCube".

I want to assign the script to the object in javascript

thanks

this is one computational intensive way:

GameObject.Find("MyCube").AddComponent("MyScript");

Just drag a drop the script to your game object.