Here’s a code example
class person
constructor: (@name, @age) ->
bob = new person("bob", 11)
if person?
alert "yes!"
else
alert "no"
In this, I test if a person class was instantiated, and it alerts “yes!” like it’s supposed to. Because bob is a person, and was instantiated.
But over here:
class person
constructor: (@name, @age) ->
if person?
alert "yes!"
else
alert "no"
I want this to alert “no”, because no person was instantiated, and yet it still alerts “yes!”
So what is the correct way to test if a class has been instantiated.
CLARIFICATION:
I do not want to test and see what bob is. I want to see if ANY FORM OF PERSON WAS INSTANTIATED.
You are testing to see if the person class is defined. This will accomplish what you want.