What is the difference between single-quoted and double-quoted strings in PHP? I'm not an expert in PHP programming, but I'm a little confused why I see some code in PHP with string placed in single quotes and sometimes in double quotes. I just know in .NET, or C language, if it is in single quote, that means it is a character, not a string. Solution: PHP strings can be specified not just in two ways, but in four ways. Single quoted strings will display things almost completely "as is."
undefined
Why does ++[[]][+[]]+[+[]] return the string “10”? This is valid and returns the string "10" in JavaScript (more examples here): ++[[]][+[]]+[+[]] Why? What is happening here? Solution: If we split it up, the mess is equal to: ++[[]][+[]] + [+[]] In JavaScript, it is true that +[] === 0. + converts something into a number, and in this case it will come down to +"" or 0 (see specification details below). Therefore, we can simplify it (++ has precendence over +): ++[[]][0] + [0] Because [[]][0] means: get the first element from [[]], it is true that: [[]][0] returns the inner
undefined
What does “use strict” do in JavaScript, and what is the reasoning behind it? Recently, I ran some of my JavaScript code through Crockford's JSLint, and it gave the following error: Problem at line 1 character 1: Missing "use strict" statement. Doing some searching, I realized that some people add "use strict"; into their JavaScript code. Once I added the statement, the error stopped appearing. Unfortunately, Google did not reveal much of the history behind this string statement. Certainly it must have something
undefined
JavaScript function declaration syntax: var fn = function() {} vs function fn() {} I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent. The previous developer uses two ways of declaring functions and I can't work out if there is a reason behind it or not. The two ways are: var functionOne = function() { // Some code }; function functionTwo() { // Some code } What