1
vote
1answer
15 views

JavaScript: using reference to “method” changes behavior

JavaScript functional programming question. Here is a screen-scrape of my node REPL session. Why does my y(4) call not push into the x array? Is there a simpler way than the function near the ...
0
votes
2answers
65 views

Queen movement in chess game(Javascript)

I am learning Javascript and as a project assignment making chess game in it. I have coded the logic for movement of Rook, Pawn, Knight and Bishop. Now I am stuck on Queen movement. A queen's move ...
0
votes
1answer
85 views

How to pass a JavaScript function to another process over JSON?

I'm doing a chrome extension -- how would I pass a function from background to a content-script instance, obviously the function needs to be serialized? Is it just okay to do eval(function_string)? ...
1
vote
1answer
37 views

Give selector.method as parameter, call it

I've got a function $.doSomething() which does some stuff and then should call other functions in the jQuery-form of $('selector').function(). I do not want $.doSomething() to know about what it's ...
1
vote
5answers
251 views

Javascript: Putting Function Pointers in an Object?

After looking around a bit, I couldn't find an answer to this question, though I suspect it's been asked before. The closest I could find is this Function pointers in objects though it doesn't get ...
0
votes
2answers
465 views

Javascript function pointer with argument as parameter in a function

Not sure if the title is worded correctly, or if there is a better way of saying it, but I think its okay. At any rate, I understand the following thus far: a.b("a", "b", "c", foo); Where "foo" is ...
0
votes
2answers
59 views

Implications of declaring a function within another function

Given the following two: Scenario 1 function inner() { // a bunch of code that does stuff } function outer() { inner(); } for(var i = 0; i < 10000; i++) { outer(); } Scenario 2 function ...
2
votes
2answers
59 views

assigning jQuery functions considered harmful?

This code was working fine: if (chk.checked) div.show(delay); else div.hide(delay); I tried to be clever by refactoring it like this: var showHide = chk.checked ? div.show : div.hide; ...
3
votes
6answers
62 views

Misunderstanding in Javascript statments

I've just started working with javascript and i saw something which i can't explain. I have js file named TestClass.js and its the following: TestClass.SetError = function (errorDescription, ...
22
votes
9answers
17k views

Javascript Function-Pointer Assignment

Consider this javascript code: var bar = function () { alert("A"); } var foo = bar; bar = function () { alert("B"); }; foo(); When running this code I get "A". Is this behavior a part of javascript ...
0
votes
2answers
98 views

How to create an array of functions into Javascript namespace script

I am trying to use an array of functions into my script. I use namespacing object and when I use this array, all my functions are undefined. How to create this array with good functions references ...
0
votes
2answers
63 views

setting onmouseenter to be a function with argument

Im trying to set the onmouseenter function for all child divs of an element in a ready callback. So the onload of body is function ready(){ for(var ...
2
votes
1answer
117 views

Calling function by value of variable and keeping scope of this pointer

I have been fiddling with code to call a function with the name of the value of a variable and then keep the this scope when called, but the this pointer seems to be in context of the element I have ...
0
votes
2answers
87 views

Javascript: Trying to set function as a member of an object in an array

I'm teachimg myself Javascript by porting a C# algebra expression compiler to Javascript. I have an OpBank object that stores the attributes of each operator, e.g., it's symbol and a pointer to a ...
0
votes
2answers
31 views

Why functionToCallOnOk I pass to my function does not get called when I attach it to callback via jQuery?

So I try such code: function showAlertWithCallback(w, h, name, body_text, functionToCallOnOk) { prepareWindow(); var ran_alert_number=Math.random()*50000; ...

1 2
15 30 50 per page