Does assigning a function handler in JavaScript create a copy or just a reference? -
i'd make sure can use function handler without generating copy every time assigned handler.
i have class handler such as:
snapwebsites.editor.prototype._someprivatefunctionhandler = function(e) { ... }
then read blob file received drag & drop:
... .on("drop", function(e) { // [...snip...] -- have tests , loop through files , // on each file: r = new filereader; r.onload = snapwebsites.editor.prototype._someprivatefunctionhandler; r.readasarraybuffer(e.originalevent.datatransfer.files[0]) } ...
when assign _someprivatefunctionhandler function onload handler of filereader, creating full copy of function or reference?
you creating reference. demonstrate:
var xyz = function() {}; var abc = xyz; xyz.someproperty = 1; abc.someproperty; /=> 1
Comments
Post a Comment