Returning a primitive variable from the function is not enough for complex application.
	Here we explore a closure to output information about object's inner life.

	
	function IAmExist () {
		var STANZA	= "I am thinking.";
		var state	= 'sleeping';
		var life = function () {
			state = STANZA + ' at ' + ( ( new Date() ).getTime() );
			setTimeout( life, 500 );
		};
		life();
		var whatIAmDoingNow = function () { return state; };	
		return whatIAmDoingNow;
	}

	// Here is the code how this object can be brought to life:
	var obj		= IAmExist();
	var demo	= document.getElementById( "display1" );
	setInterval( function () { demo.innerHTML = obj(); }, 100 );


	
	
Here we use liteweight object `{}`, similar to "structure" in C. Alternatively we can use Array construct the same way, so there is still nothing like Classes and objects from "heavy-lifting classical" OOP of C++. function IAmExist2 ( myDisplay ) { var STANZA = "I am thinking."; /// condition of an individual var state = { startTime : ( new Date() ).getTime(), action : 'sleeping', age : 0, myDisplay : myDisplay // where i am diplayed in outside world }; /// periodically refreshes life of an individual var life = function () { state.age = ( ( new Date() ).getTime() ) - state.startTime; state.action = STANZA; setTimeout( life, 500 ); }; life(); var whatIAmDoingNow = function () { return state; }; return whatIAmDoingNow; } // Here is how this constructor can be used: var demo2 = document.getElementById( "display2" ); var obj2 = IAmExist2( demo2 ); setInterval( function () { var state = obj2(); demo2.innerHTML = state.action + ' My age is ' + state.age + '. I am displayed on ' + state.myDisplay.getAttribute( 'id' ) + '.'; }, 100 );
Our object has no public properties. It is public property itself, because it is a function which returns some private information. If we have few public methods we need to return them all. Since we already using structure-like construct `{}`, we just put our methods there and return them at the bottom of IAmExist2() function: .... var self = {}; self.whatIAmDoingNow = whatIAmDoingNow; self.timeToAskForFood = function() { return 60000 - state.age; }; // begs for food every minute return self; } That's not new: our model became ideologically the same as "functional model" described in Douglas Crockford, [ 5 ], section "Functions.Functional". What our model does now is the instantiation: function -> object from constructor IAmExist2(): IAmExist2, IAmExist2, .... | | V V object1 object2 But this model lacks another way to bookkeep our mental and computing resources: horizontal level of inheritance.