I am a beginner in Knockout and I must say I often get confused regarding when to use (). Is there any general tip/trick regarding when would you use () against when you would not because at the moment I am just doing trial and error. If the binding throws error or doesn’t update values I remove () else I put.
I am a beginner in Knockout and I must say I often get confused
Share
You use
()in knockout when using observables or when executing any other method.Knockout observables are functions, invoked to return you what you looking for or allow you to assign new values.
In knockout you use
object.property()to retrieve a value andobject.property(newValue)to assign a value to that property.On the knockout website checkout the documentation, specifically the section on observables, which shows you the use of the
()when querying and writing observables.To quote:
Knockout’s interactive tutorial is also quite nice and well worth going through.