defined

if(defined x)
Looks better than if(typeof x ==='undefined')?

In most cases, you can (and should) write just

if (x !== undefined)

It's only when dealing with possibly undeclared variables that you need to use typeof, and those cases are rare enough to not warrant special syntax.

I am asking if it is defined goddamnit, not if its type is undefined. That should sound like same thing, but google searches doesnt make best programming language.

Let’s calm down please :-)

I understand that you’re saying “is x defined” sounds clearer than “is the type of x undefined”, and i agree!

However, since the way to check for definededness is well understood, and since adding new syntax is a large change and thus requires a very compelling reason to add, how would you persuade those who don’t think it’s worth it?

1 Like

There should be hook method for syntax in every engine.

e.g. python has customizable grammar by file next to source, adding new syntax to langs is easy.

I just think that typeof undefined... it's clumsy.