Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

call_once

oatkiller edited this page Sep 13, 2010 · 2 revisions

use it on a function to get a verison of the function that only runs the first time

(function () {

var get_a_div = function () {
	return document.createElement('div');
}[o.call_once]();

var my_div = get_a_div(), // returns a new div

// returns the same div again,
// as the function is called only once
my_same_div = get_a_div();

my_div === my_same_div; // true. 

})();
Clone this wiki locally