arrayLikeType (rkatic)

HTML

<ul id="log"></ul>

CSS

li.pass { background: #02C500; }
li.fail { background: red; }

JavaScript

function Stack() {
    this.length = 0;
}

var _push = [].push;

Stack.prototype = {
    add: function() {
        _push.apply( this, arguments );
    },
    pop: function() {
        if ( this.length ) {
           return this[ --this.length ]
         }
    }
};

var s = new Stack();

test( s );
s.add( 1, 2, 3 );
test( s );
s.add( 0 );
test( s );
    
function test( obj ) {
   var keys = $.map( obj, function( v, k ) {
        return k;
   });
   
   console.log( keys );
   var pass = keys.length === obj.length;
   
   $("<li>").text( keys.length + "==" + obj.length ).addClass( pass ? "pass" : "fail" ).appendTo("#log");
}