Linked Questions
17 questions linked to/from javascript - How to make this code work?
3263
votes
45
answers
490k
views
JavaScript closure inside loops – simple practical example
var funcs = [];
// let's create 3 functions
for (var i = 0; i < 3; i++) {
// and store them in funcs
funcs[i] = function() {
// each should log its value.
console.log("My value:", i);
...
4
votes
4
answers
33k
views
Javascript rotation animation
I am stuck at a point.There are 10 straight lines(png image).What I want is after the first line rotates by 40 deg,then the second line should start its rotaion and then the third,fourth,fifth and so ...
user avatar
user2412575
1
vote
6
answers
6k
views
What are immediate functions used for? [duplicate]
I've been programming in JS since some time, but I have never came upon a need of using immediate functions, for example:
(function(){
console.log('hello, I am an immediate function');
}())
What ...
1
vote
3
answers
8k
views
select multiple rows using control and shift key
Demo
<table id="tableStudent" border="1">
<thead>
<tr><th>ID</th><th>Name</th> <th>Class</th></tr>
</...
1
vote
2
answers
604
views
is if block a separate closure in javascript
From what i know, a function say A defined within another function say B has access to local variables of B as well.
function B() {
var x = 10;
function A() {
console.log(x); //...
0
votes
1
answer
1k
views
Without jQuery, make a "show more" "show less" a href
I know this is fairly straight forward using jQuery but for college assignment need to insert new paragraphs on clicking more link then remove them on clicking less links - we are not to use css or ...
4
votes
2
answers
542
views
Javascript: What happens to objects that don't have a name?
If I do the following (in the global scope):
var myObject = {name: "Bob"};
I have a way to point to that object in memory (i.e. the string identifier "myObject)". I can open the console and type: ...
2
votes
3
answers
737
views
Return a dynamically generated function without eval()
I'm trying to dynamically create function when iterating over an array and
I need the arguments in the array to be set according to the value of the current index.
For example:
var array = ['apple',...
0
votes
1
answer
974
views
Closures in recursion
i have this two recursive functions in javascript.
first function returns digits of the input number in right to left order
second function returns them in left to right order.
function first(n){
...
3
votes
3
answers
191
views
Javascript Function Declaration Options
I've seen experts using below to declare a function:
(function () {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
//etc
}()...
1
vote
3
answers
127
views
Can someone explain why this javascript code alert these (item3 undefined, item3 undefined, item3 undefined) [duplicate]
function init(list) {
var result = [];
for (var i = 0; i<list.length; i++) {
var item = 'item' + list[i];
result.push( function() { alert( item + ' ' +list[i] ) } );
}
...
1
vote
1
answer
97
views
Modifying an element of array $(this)
I'm using a 3rd party javascript library which requires a nested array to be passed to a function. I'm using this function several times, and so storing the array in a variable and passing it to the ...
-4
votes
3
answers
132
views
JavaScript object properties - connect them together? [closed]
I have 3 objects in an array.
myArray = [
{name: "iPhone", link: "www.apple.com"},
{name: "Nokia", link: "www.nokia.com"},
{name: "Google", link: "www.Google.com"}
]
How to make a loop and put ...
0
votes
1
answer
80
views
JavaScript Object Reference
I've seen many questions for that context, but I still can't figure out, what exactly my Problem is. (I'm still experimenting with JavaScript, especially with objects)
Code:
function Field(val)
{ ...
0
votes
2
answers
82
views
How to defined Global variable scop in javascript
I want to use a variable inside another function but is not defined! I tried it with this and var. how can I make it defined in another function? in the code below, I want to add actionInt by 1 in "...