Linked Questions

697 votes
13 answers
148k views

Is JavaScript guaranteed to be single-threaded?

JavaScript is known to be single-threaded in all modern browser implementations, but is that specified in any standard or is it just by tradition? Is it totally safe to assume that JavaScript is ...
Egor Pavlikhin's user avatar
485 votes
15 answers
160k views

How to "properly" create a custom object in JavaScript?

I wonder about what the best way is to create an JavaScript object that has properties and methods. I have seen examples where the person used var self = this and then uses self. in all functions to ...
Michael Stum's user avatar
359 votes
10 answers
396k views

Can I set variables to undefined or pass undefined as an argument?

I’m a bit confused about JavaScript’s undefined and null values. What does if (!testvar) actually do? Does it test for undefined and null or just undefined? Once a variable is defined can I clear it ...
AJ.'s user avatar
  • 11.3k
120 votes
6 answers
48k views

How do I pass the value (not the reference) of a JS variable to a function? [duplicate]

Here is a simplified version of something I'm trying to run: for (var i = 0; i < results.length; i++) { marker = results[i]; google.maps.event.addListener(marker, 'click', function() { ...
ryan's user avatar
  • 2,331
39 votes
13 answers
15k views

What are the top JavaScript pitfalls? [closed]

I'm planing on giving an introduction talk on JavaScript and in the preparation process I wondered what the top pitfalls are that rookies fall into. I know I've had a few gotchas before I fully ...
47 votes
12 answers
13k views

Why am I finding Javascript/jQuery so difficult to get right?

My background is in C and I've picked up PHP, mySQL, HTML, CSS without too much issue. But I'm finding Javascript/jQuery surprisingly difficult to get right. Very frustrating. Why? It seems to ...
JMan's user avatar
  • 1,815
55 votes
2 answers
15k views

How is a JavaScript string not an object?

A comment by Vítor De Araújo on a blog post by Douglas Crockford points out that the two are not the same. He gives an example showing that a string is not like an object: A string object and a ...
Ian Boyd's user avatar
  • 259k
14 votes
3 answers
4k views

Referencing a JavaScript value before it is declared - can someone explain this

I'm hoping someone can explain to me why the below JavaScript/HTML will show "door #2" when the HTML is viewed in a browser: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://...
Frank Schwieterman's user avatar
13 votes
4 answers
3k views

JS Object this.method() breaks via jQuery

I'm sure there's a simple answer to this, but it's Friday afternoon and I'm tired. :( Not sure how to explain it, so I'll just go ahead and post example code... Here is a simple object: var Bob = { ...
Peter Boughton's user avatar
4 votes
5 answers
4k views

bold, header effects in alert()?

in javascript, how to make alert bold n use h1 to h5 headers? Is this possible or simply plain alert is option? how to include bold and h1 to this alert? function onlooad() { alert("wssup??"); }
Abhilash Muthuraj's user avatar
6 votes
2 answers
23k views

Javascript Global Variables Not Working as expected. Help?

I am new to Javascript. I am facing a problem with global variables. I can't figure out that why the global variables are not working as the code looks ok. Please Help me solve this problem. I will ...
Naeem Ul Wahhab's user avatar
5 votes
2 answers
523 views

PHP url functions and subdomains

I have a website thenoblesite.com. It has some subdomains i.e. download.thenoblesite.com wallpaper.thenoblesite.com etc. Pages for subdomains are present in the main htdocs folder i.e. ...
Naeem Ul Wahhab's user avatar
-1 votes
3 answers
5k views

JavaScript object not working

I am facing a problem with JavaScript objects. I have some text on a page which should converts into textfield when clicked. The problem is that when I click the text the console displays the error ...
Naeem Ul Wahhab's user avatar
1 vote
4 answers
2k views

Insert code into body of function at runtime

Coming from Java with experience in bytecode editing, I was wondering if I could change the bodies of functions at runtime with Javascript. For this question, let's use the following code as example: ...
Stephan Bijzitter's user avatar
-1 votes
2 answers
675 views

PHP automatically renaming downloaded files

I am new to PHP. I have a software downloads website. What I want is to automatically add "-mysite.com" with every download filename. So that the actual filename remain the same i.e "somesoftware....
Naeem Ul Wahhab's user avatar

15 30 50 per page