Message from JavaScript discussions

December 2016

— Convolution

— 


huh, why does this not work?

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

— I get unexpected token on the colon of the object literal

— Can you not write object literals in ternary logic?

— What is the error?

— Unexpected token

— The colon after

uris

— I wonder if embedding the literal in

new Object()

would work

— Try

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

Message permanent page

— I did, to no effect

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