General computer language, syntax question.

Ian Kelly ian.g.kelly at
Mon Feb 29 09:54:05 EST 2016

On Feb 29, 2016 7:11 AM, <jonas.thornvall at> wrote:
> Sorry but would not if (array==empty) suffice and be alot clearer?

In Python, you can just do "if len(array) == 0" or "if not array".

In JavaScript you have "if (array.length === 0)". Is there some problem
with that?

I would prefer this over your suggestion since it doesn't require some
variable named "empty" to have a sensible value set.

On the container test, as others pointed out, Python has the "in" operator.
JavaScript has a draft Array.prototype.includes method, but it doesn't have
broad cross-browser support yet.

More information about the Python-list mailing list