happy new year, and I have the following issue with knockoutjs if statement.
I have the following
z.object = ko.observableArray(ko.utils.arrayMap([{"Id":3,"Date":"2014"}]))
<div data-bind="text: Date"></div>
above prints fine, 2014 but below if statement does not work.. what is going on?
<!-- ko if: Date === 2014 -->
<!-- /ko -->
I am totally baffled by this.
From SO answer here:
The identity (
===) operator behaves identically to the equality (==) operator except no type conversion is done, and the types must be the same to be considered equal.So in your statement
Date === 2014, hereDateis tring and2014is number, then result is false.Either convert string to number, number to string or use
==instead of===.