Tagged Questions
32
votes
7answers
10k views
javascript: recursive anonymous function?
Lets say I have a basic recursive function:
function recur(data) {
data = data+1;
var nothing = function() {
recur(data);
}
nothing();
}
How could I do this if I have an ...
8
votes
6answers
374 views
jQuery recursively remove empty children
I have a nested set of html tags and i want to delete all tags and their children without text.
Example:
<div id="mydiv">
<span></span>
<span><br></span>
...
3
votes
1answer
168 views
Algorithm to create n-th level of nested patterns in RegEx
As explained in Can regular expressions be used to match nested patterns?, it is not possible to create regex to match arbitrary nested pattern. But is it possible to create an algorithm that would ...
5
votes
5answers
3k views
recursively concatenating a javascript functions arguments
I came across a javascript puzzle asking:
Write a one-line piece of JavaScript code that concatenates all strings passed into a function:
function concatenate(/*any number of strings*/) {
...
4
votes
2answers
2k views
jQuery/JavaScript: My recursive setTimeout function speeds up when tab becomes inactive
I've got an odd little dilemma in this jQuery slideshow plugin that I am building.
It's nothing fancy and the code I have written to date is working great however I have noticed that when I leave the ...
4
votes
2answers
633 views
Crockford's hanoi function (from “The Good Parts”)
at the moment I'm reading Douglas Crockford's book, and the towers of hanoi function is a bit over my head. Even with logging stuff to the console I wasn't able to really understand what's going on. ...
6
votes
3answers
10k views
Iterating through all the <div> tags on a page
I want to go through all the elements on a page using Javascript and see if they have a property set. Is there an easy way to do this, or do I have to use a recursive solution?
2
votes
4answers
3k views
Is there a way to make this slideshow move automatically?
This is the slideshow that we used:
http://www.littlewebthings.com/projects/blinds/
and this is the JS file:
http://www.littlewebthings.com/projects/blinds/js/jquery.blinds-0.9.js
However, this ...
1
vote
4answers
104 views
How does `arguments.callee` refer to anonymous functions?
A script was needed to quickly tell me how many html comments there are on the page and what their contents are. Using an anonymous function for recursive DOM traversal seemed appropriate:
var ...
4
votes
2answers
2k views
Calling a javascript function recursively
I can create a recursive function in a variable like so:
/* Count down to 0 recursively.
*/
var functionHolder = function (counter) {
output(counter);
if (counter > 0) {
...
3
votes
5answers
5k views
Recursively parsing JSON
I have a large JSON object that I created with Python, and I'm needing to display the information on a webpage now. My problem is the size of it; there are nested arrays and objects within, and it is ...
3
votes
2answers
619 views
Use recursion instead of EVAL
I have a list of items in a page that must be hidden in sequence, but just after the previous item has been totally hidden.
I made the following code, where I create a big string inserting the ...
2
votes
5answers
2k views
How exactly does this recursive function work in JavaScript?
I have the following example of a recursive function, and what I don't understand is the order in which things are happening:
function power(base, exponent) {
if (exponent == 0)
return 1;
...
2
votes
2answers
315 views
Recursively creating a JSON tree, adding only at the deepest level
I want to create a JSON hierarchy structure of unknown objects, so it must be handled recursively.
Here's my function, where angular.element.isEmptyObject() is inherited from jQuery, and ...
2
votes
1answer
108 views
Object nested property access
I'm trying to write a function that adds an accessor for each nested property in an object. To make this a bit clearer, given object o, and a string representing a path, I should be able to access the ...