how can I check if an object is null?

in myconsole i keep geting this error when a dragon(with the name of cube) gets destroyed()

MissingReferenceException: The object of type ‘Transform’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

i was reading this post and from what i understand i would change it to this?

if (Transform)
transform(Rect(0,0,500,500),transform);

is this wrong …or what is the proper way to do this?

Yes, that’s wrong; the correct way is to refer to the object, not the type.

var someObject : Transform;

function Start () {
    if (someObject != null) {
        // do something
    }
}

For future reference:

Unity overloads the == operator. Thats why if(gameObject == null) will return false even though the object is destroyed ( but not collected by the GC )

The only safe way to do this check is avoid the == operator and use the ?? instead - that one is not overwritten and plain C#

if(gameObjectToTest??false){
    // this will only execute if gameObject is not destroyed
}

Detailed information can be found here : Custom == operator, should we keep it? | Unity Blog

public ItemContent itemcontent;
// Object Declartion and make a class
// ItemContent Just Check object is null or not…simply
if(itemcontent != null) {
Debug.Log(“item content is notnull”);
} else {
Debug.Log(“item content is null”); }
// -----------------------OR--------------------------------
if( itemcontent == null)
{
Debug.Log(“item content is null”);
} else {
Debug.Log(“item content is not null”); }
========================================

I think you have to use
DontDestroyOnLoad(gameObject);
in this way your game object will not get destroyed .
Use this when the script loads ( void start())
I hope this is usefull in any way

having the same problem over here var enemies: GameObject;

function OnDestroy ()
{
enemies.SetActiveRecursively(true);

if(gameObject==null){
Destroy(this);
}
else;

}