//creando la clase pila var Stack = function(size){ this.Size=size; this.Stacker = new Array(size); this.pointer=0; //funciones //inserta a la pila this.Push = function(cadena){ if(this.IsFull()==false){ this.Stacker[this.pointer]=cadena; this.pointer++; return true; } else{ return false; } } //saca de la pila this.Pop = function(){ if(this.IsEmpty!=true){ this.pointer--; return this.Stacker[this.pointer]; } else{ return false; } } //esta vacia? this.IsEmpty = function(){ if(this.pointer==0) return true; else return false; } //esta llena? this.IsFull = function(){ if(this.pointer==this.Size) return true; else return false; } }
Pila en javascript
September 13, 2007 – 12:00 am
3 Comments
Gracias, pero, pues, si el Array ya contiene un push y actúa como pila, entonces, ahorraríamos mas código. Esta era solo una manera de explicar los multi-usus que tiene javascript.
muy bien pero seria mejor usar prototype para reducir codigo
es muy bueno que por medio del esta pagina nos ayuden sobre este tema pero mejor si nos dan mas ejemplos
bye se cuidan