1

I am not quite sure what this statement intends to do:

function create (possibilities) { var move = Q.defer(), app = express(), fake = possibilities.fake || {},

Confused with function parameter used with variable declaration.

Links to the reference documents explaining this would help. Thanks!

Subodh
  • 11
  • 2
  • 1
    The Or operator? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR_() – epascarello Apr 04 '17 at 22:00
  • Not really, however, a bit confused about using defined function's attribute being used within var declaration. How can it have a property as well? 'Learning javascript' – Subodh Apr 05 '17 at 14:53
  • It does not have a property. It is referencing what is in the property. If there is nothing in that property, than it uses a default. The line is basically. `if(possibilities.fake!==undefined) { fake = possibilities.fake; } else { fake = {} }` It is a basic pattern where you have an object that has overrides. If the override is not there, than you set it to the default value. Other way of doing it is to use Object.assign or extend. – epascarello Apr 05 '17 at 15:18

0 Answers0