I ran into this when returning data for a table, but only having some columns sortable.
<tr data-bind="foreach: ArrAsrColumnHeaders">
<th class="sortable koJson" data-bind="
css: {active: ((typeof(isActive) != 'undefined') ? isActive : '')}
, text: text
, attr:{href: ((typeof(jsonClick) != 'undefined') ? jsonClick : '')}">
</th>
</tr>
This says that, for each column in the table's header, add the class 'active' if 'isActive' is defined and set to true, but don't freak out if it isn't there. The same goes for adding a 'href' attribute.
Disclaimer: I don't understand knockout well enough to know the limitations of this approach, but this worked for me in my case, whereas, the more straightforward approach of css: {active: isActive() || ''}
threw errors.