-4
jBox.prototype.position = function (options)
{
  // this line
  !options && (options = {});

}

In conventional programming boolean statements are used in if else statements. What does !options && (options = {}); translate too?

options is a json or array. What does !options mean?

options = {} is assigning a empty json to variable options, how does it return a boolean value to be used with &&.

user6708151
  • 63
  • 1
  • 11

2 Answers2

2

The code:

!options && (options = {});

is the equivalent of:

if(!options) { 
    options = {}; 
}
Faly
  • 12,529
  • 1
  • 16
  • 34
0

It means that if options is a falsy value (empty) then initialize it with an empty object literal.

void
  • 33,471
  • 8
  • 45
  • 91