How does the 'value' keyword actually work in JavaScript, can we get a value and assign it at the same time?
<p>I wandered a lot to understand this but cannot get any answer specifically related to my question, what i am trying to ask is that how does the 'value' key word returns the value of the textbox or any other element and we can assign at the same time.</p>

<p>we do not use parenthesis so that according to my understanding is not a function.</p>

<p>I am trying to create an object with a property, lets call it 'val' which will return the value and ill be able to assign a new value by using the equals to operator.</p>

<p>hard coded values work but how to get it dynamically? will i create a function which will fire every time a value is inserted and assign it to the property? or how will it work? because i cant clearly make it a function which returns a value because i wont be able to assign it then.</p>

<pre><code>var searchBar = {
   element : document.getElementById('memSearchInput'),
   val : document.getElementById('memSearchInput').value.trim(),
 }
</code></pre>

<p>this clearly dosent work.</p>

<p>I havent posted many questions, so if this was not clear, sorry for it. </p>