Is there a specific reason to use "that?"
Note about using "that": I found a thread explaining "that" :What does 'var that = this;' mean in JavaScript?. One of the respondants said: "By convention, we make a private that variable. This is used to make the object available to the private methods. This is a workaround for an error in the ECMAScript Language Specification which causes this to be set incorrectly for inner functions." Thus, I am confused if the "that" here has any special usage.
In addition, Why not simply assign a var name to replace that.push? Thank you very much.
var LinkedList = function(e){
var that = {}, first, last;
that.push = function(value){
var node = new Node(value);
if(first == null){
first = last = node;
}else{
last.next = node;
last = node;
}
};
that.pop = function(){
var value = first;
first = first.next;
return value;
};
var Node = function(value){
this.value = value;
var next = {};
};
return that;
};