Use JS hack-reference to improve speed
Hello!
I found on "wtfjs.com" a method to do JS-reference, as the & in php.
MAYBE this can improve JS.
This is the basic idea:
- function x(object){
- // I need re-use object on another method
- reUse(object); // I suppose that JS copy object to reUse function
- console.log(object);
- // Here is different, JS will pass a reference of object, but it's strange...
- reUseAgain(arguments);
- console.log(object);
- }
-
- function reUse(object){
- object = 1;
- }
-
- function reUseAgain(object){
- object[0] = 1;
- }
-
- x(0);
- // log: 0 (without reference)
- // log: 1 (with reference)
Or be, jQuery probably (I don't know) copy too many times objects. With arguments method this can be changed. But it will really improve speed?
I cannot do this test with certain, if an expert can do, then show to us! :)
Bye.