For instance, if I have:
<div data-bind="visible: viewModel.property1() || viewModel.property2()" />
… if viewModel.property1() is true, does knockout still evaluate viewModel.property2()?
Similarly, if we have:
<div data-bind="visible: viewModel.property1() && viewModel.property2()" />
… if viewModel.property1() is false, does knockout still evaluate viewModel.property2()?
If it does then I will bare this in mind when trying to optimise my bindings.
Thanks in advance.
Yes, it does short circuit.
The right hand side of the bindings is evaluated as a block of arbitrary javascript, and since && and || short cirtcuit in javascript…