mercredi 4 mars 2020

Another way to write if statements in Javascript? [duplicate]

I was checking the code in a library and I found this little piece:

if (typeof options === 'function') (callback = options), (options = {});

Is this just another way of writing

if (typeof options == 'function) {
  callback = options;
  options = {};
} 

?

It's just that I've never seen an if statement declared like this and wondered if this is accepted, maybe, only in Javascript?

Aucun commentaire:

Enregistrer un commentaire