I have no issues in posting in JSBIN, but the code is pretty simple I am directly giving you the HTML file. I have scanned it so you can download and open in browser w/o facing any virus issues.
Rest what I was trying can be done in browser console. thanks.
If you check the temp variable you’ll see that it’s correctly assigned the button to the temp variable.
Where the undefined is coming from is the var statement itself. The variable temp is correctly assigned, and the var statement itself doesn’t return any value which is why you’re shown undefined. There’s nothing bad about that.
Statements return values so that their results can be interpreted.
A variable definition can never fail; it can receive ‘bad’ input, but it can never fail itself given legitimate (or interperably legitimate) values.
Thus the language construct of a variable definition has no return type - the statement will always succeed, and the results can be checked by inspecting the already defined variable.