Comments for Marcos Cáceres' blog https://marcosc.com By reading this blog you've signed an NDA. Fri, 04 Sep 2020 06:44:32 +0000 hourly 1 https://wordpress.org/?v=6.4.8 Comment on Dynamic function names in JavaScript by Leonardo Danza https://marcosc.com/2012/03/dynamic-function-names-in-javascript/#comment-86505 Thu, 02 Feb 2017 10:14:19 +0000 http://marcosc.com/?p=273#comment-86505 i found this on (http://http://helephant.com/2008/08/23/javascript-anonymous-functions/) but i appreciate other arguments for my learning of javascript :

The function’s name can be used to call the function from inside the function itself. That can be useful for recursive functions.

var thingsToDoToday = function flyToTheMoon() {
if(!onTheMoon)
flyToTheMoon();
else
alert(“One small step for a man..”);
}
thingsToDoToday();

It can also useful for debugging because you can see the function’s name in a call stack. Anonymous functions generally all look the same in the call stack. If you have a nasty debugging situation, sometimes giving names to the functions you are interested in can make things clearer.

]]>
Comment on Dynamic function names in JavaScript by Leonardo Danza https://marcosc.com/2012/03/dynamic-function-names-in-javascript/#comment-86504 Thu, 02 Feb 2017 10:06:07 +0000 http://marcosc.com/?p=273#comment-86504 I don’t well see the usefullness of adding a name to the function object created with the constructor…
code:
var d = document.body.appendChild(document.createElement(“div”));
d.style.border = “solid 1px red”;
var print = (function() {
var a = 0;
var p = function(txt) {
var el = d.appendChild(document.createElement(“div”))
el.innerHTML = String(a) + “: ” + txt;
a++;
}
return (p)
})();

var name = “foo”;
var customAction = function(x, y) {
print(“x+y=” + (x + y));
};

//implement it
var func = new Function(“action”, “return function ” + name + “(x,y){ print(action.toString());action(x,y) };”)(customAction);

//test it
func(1, 2);
print(func.toString());

customAction = {};
func(1, 2);
print(func.toString());
print(customAction);

// is name useful ??

var f1 = function fun1(x, y) {
return (x + y)
};
print(f1(1, 2));
try {
print(fun1(1, 2))
} catch (er) {
print(er.message)
};

print(f1.name);
oputput:
0: function (x, y) { print(“x+y=” + (x + y)); }
1: x+y=3
2: function foo(x,y){ print(action.toString());action(x,y) }
3: function (x, y) { print(“x+y=” + (x + y)); }
4: x+y=3
5: function foo(x,y){ print(action.toString());action(x,y) }
6: [object Object]
7: 3
8: fun1 is not defined
9: fun1

]]>
Comment on Putting APIs behind a pref in Gecko by Putting down event infrastructure in Gecko – Marcos Cáceres' blog https://marcosc.com/2016/06/putting-apis-behind-a-pref-in-gecko/#comment-85293 Tue, 11 Oct 2016 05:33:40 +0000 https://marcosc.com/?p=424#comment-85293 […] Putting APIs behind a pref in Gecko […]

]]>
Comment on Dynamic function names in JavaScript by Pattabi https://marcosc.com/2012/03/dynamic-function-names-in-javascript/#comment-83870 Wed, 28 Oct 2015 11:44:05 +0000 http://marcosc.com/?p=273#comment-83870 Hi,

I found your page while I was looking for help with my requirement.

In my case, I want to return a value from the dynamic function

Pasted the code below, the custom function is getting executed but am getting ‘undefined’ for ‘returned’. Would you be able to help with this?

Thanks

var customFunction = function (name, data) {

return ‘something’;

};

var returned = null;

returned = func(e, results[e]);

console.log(returned);

if(returned){

group._currentData= returned;

}

]]>
Comment on Zip files and Encoding – I hate you. by Jason https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/#comment-83847 Sun, 25 Oct 2015 07:41:26 +0000 http://datadriven.com.au/?p=112#comment-83847 I have just faced similar problem of the file name encoding in MAC. My friend has sent me some files, after decompression, the file names look weird. My solution is to use another program which supports unzip with another encoding instead of using the unzip program which comes with MAC OS

]]>
Comment on Gecko: gBrowser and tabs by anon https://marcosc.com/2015/01/gecko-gbrowser-and-tabs/#comment-83509 Fri, 11 Sep 2015 14:52:31 +0000 https://marcosc.com/?p=406#comment-83509 Doesn’t look that undocumented:
https://developer.mozilla.org/en-US/docs/Web/Events/pageshow

]]>
Comment on Nested inheritance in Javascript by Omer Moran https://marcosc.com/2012/04/nested-inheritance-in-javascript/#comment-82648 Wed, 13 May 2015 15:03:49 +0000 http://marcosc.com/?p=287#comment-82648 Hi,
Why not just using OLOO?
Objects Linked to Other Objects?
Take a look at this method:
http://davidwalsh.name/javascript-objects-deconstruction

]]>
Comment on Gecko: gBrowser and tabs by Andreas Tolfsen https://marcosc.com/2015/01/gecko-gbrowser-and-tabs/#comment-82246 Thu, 26 Mar 2015 14:14:01 +0000 https://marcosc.com/?p=406#comment-82246 You also need to set the preferences `devtools.debugger.remote-enabled`, `devtools.debugger.chrome-enabled`, and `devtools.chrome.enabled` for the `-jsdebugger` argument to work the first time.

]]>
Comment on Transitioning to TLS by Bruce Lawson’s personal site  : Reading List https://marcosc.com/2014/12/transitioning-to-tls/#comment-81942 Fri, 06 Mar 2015 16:30:44 +0000 https://marcosc.com/?p=385#comment-81942 […] Transitioning to TLS – web standards dreamboat @marcosc writes up how he did it (and “triggered a cascade of shit”) […]

]]>
Comment on Gecko: gBrowser and tabs by Garvan Keeley https://marcosc.com/2015/01/gecko-gbrowser-and-tabs/#comment-81512 Fri, 30 Jan 2015 05:40:03 +0000 https://marcosc.com/?p=406#comment-81512 Sigh… the plethora of undocumented events. Thanks for writing this stuff up Marcos, keep going.
I still toast the day we both found out about the purgecaches flag.

]]>