This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Please try following: window.requestAnimFrame = (function(callback) { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60); }; })(); "callback" is marked as unused Product Version: NetBeans IDE 7.3 RC2 (Build 201302050851) Java: 1.7.0_13; Java HotSpot(TM) Client VM 23.7-b01 Runtime: Java(TM) SE Runtime Environment 1.7.0_13-b20 System: Linux version 3.2.0-35-generic-pae running on i386; UTF-8; en_US (nb)
The first parameter "callback" in this case is really unused. The return statement contains a usage of "callback" parameter that is a parameter of the function wrapping the usage.
I'm not sure, I simplified it to this: var a = (function(callback) { return false || function(callback) { alert(callback); }; })(); a(2); And alert window contains 2. I think that because on the last line the function is called immediately, the first parameter is passed to the second one.
Thanks, I get it:). Unfortunately I don't have doubt how to solve this. So lets keep it as reminder.
The correct code would be: ``` window.requestAnimFrame = (function() { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60); }; })(); ``` Note that this will also give "2": ``` var a = (function() { return false || function(callback) { alert(callback); }; })(); a(2); ``` This would also work the same: ``` var a = function(callback) { alert(callback); }; a(2); ``` Note that you simply define an anonymous function and "save" it to a variable `a` (in first case you return the function as a value). And callback in original code is really unused (as it is shadowed by function argument). This will give you "outside": ``` var a = (function(callback) { callback = "inside" return false || function(callback) { console.log(callback); }; })(); a("outside"); ``` This will give you `undefined` (because you haven't passed any parameters) and "outside": ``` var a = (function(callback) { return false || function(callbackInside) { console.log(callback); console.log(callbackInside); }; })(); a("outside"); ``` This will give you "calling anon" and "outside": ``` var a = (function(callback) { return false || function(callbackInside) { console.log(callback); console.log(callbackInside); }; })("calling anon"); a("outside"); ```
You're right of course, the "proof" in comment #2 does not really prove anything :). Thank you for noticing that.