Message from JavaScript discussions

December 2016

— Try

— 

Var selected = idnum ? ({uris: [state.itemEntryContainer[idnum].uri]}) : state.itemEntryContainer.list();

— I did, to no effect

— I figured out why. It is being intetpreted as a block statement, not an object

— Usually var gives context to literals

— So if I give my variable declaration as an operand of the ternary, it would work, as well as using Object()

Message permanent page

— 

var selected = idnum ? new Object({uris: [state.itemEntryContainer[idnum].uri]}) : state.itemEntryContainer.list();

works :)

Message permanent page

— Turns out I was writing the ternary wrong the entire time

— Haha, why?

— I swapped the colon and question mark

— 

conditional : iftrue ? iffalse

= wrong

— 

conditional ? iftrue : iffalse

= right