I don't quite understand the difference between the following two lines of code. In my code, the line with "apply" works the way I want it to, and the line with just regular push doesn't.   So what is really going on when both of thes...
In Chrome and Node, the following code throws an error:  function noop() {} var a = new Array(1e6) // Array[1000000] noop.apply(null, a) // Uncaught RangeError: Maximum call stack size exceeded   I understand why it might be a Bad Idea to pass 1 mill...
I'm learning JavaScript and I'm currently trying to figure out why (in Spidermonkey)  [].concat.apply([1], [[2]])   returns the expected [1, 2], but  Array.concat.apply([1], [[2]])   returns [2] instead of [1, 2].  Could someone provide a goo...
In JavaScript, I can use apply to pass an array as arguments to a function:  var f = function (n,m) {},     args = [1,2];  f.apply(null, args);   I now need to do something similar in PHP i.e. pass an array of items as 'separate' arguments to...
How does the Math.max.apply() work?.  <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>JS Bin</title> </head> <body>   <script>       var list = ["12","23","100"...
I wanted to invoke a function using the javascript apply() method. This works fine if the function has no arguments. i.e.  function test() {   console.log(this); }  body = document.getElementsByTagName("body")[0]; // shortcut to body element...
It's frustrating to have to manually set the scope of an object every time I declare a callback in JavaScript, but it's a fact of life. I wondered if I could do it by passing [mycallback].apply as the callback, and the scope object as an argu...
In Jeremy Ashkenas's awesome Underscore.js library, I tried to understand one thing about the source file. I do not understand this:  var slice = Array.prototype.slice; args = slice.call(arguments, 2);   So that:  args = Array.prototype.slice.cal...
I'm writing a global error handling "module" for one of my applications.  One of the features I want to have is to be able to easily wrap a function with a try{} catch{} block, so that all calls to that function will automatically have th...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.