Such input field:

<input type="text" name="admin_id"> 

With jQuery, I safely get the value of this field, but it does not want to be written to a variable. I bring a dialogue from Chrome

enter image description here

    1 answer 1

    Everything is recorded with you, the console just messed up you. In short, var a = 100 is a construction. The same construction as, say, if (true) {} . Constructs always return undefined and cannot be used in expressions, since This will result in a syntax error. For example, console.log(var a = 100) will output an error.

    And, for example, a = 100 (without var ) is an expression that returns the result of execution (in this example, the number 100). And expressions can be used inside other expressions, for example console.log(a = 100) .

    Details about this can be found here .

    Console screenshot