Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*"
Favorites infavorites:mine
Status closed:yes
Types is:question
Exclude -[tag]
For more details on advanced search visit our help page
Results tagged with Search options user 35841

JavaScript (not to be confused with Java) is a high-level, dynamic, multi-paradigm, weakly-typed language used for both client-side and server-side scripting. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.

For Method 1, the function and its symbol is processed by the parser before any code in this file is run. Thus the definition is "hoisted" to the top of whatever scope it is in and the symbol can be …
answered Feb 26 '15 by jfriend00
An array in Javascript can be sparse where only some elements exist and the first element that exists does not have to be at index 0. But, the .length property is always measured from index 0. var … Is it necessary to mention zero-indexed array? It's not really necessary in Javascript since that is the default expectation, but does confirm that whatever values you are expecting in the array will start at the 0 index. …
answered Dec 13 '15 by jfriend00
It sounds like you aren't understanding how promises are used. You return a promise. Then, later when your code resolves the promise, it resolves it with a result and that result is passed to the .t …
answered Apr 22 '15 by jfriend00
The Chrome debugger will allow you to expand minified code into multiple lines to make it easier to step through and set breakpoints in it. It has a {} symbol below the code window. When you click o …
answered Nov 10 '14 by jfriend00
I'd much rather see code that returns an object for success and null for not success. Then, it at least feels like the function is behaving consistently. It's return either an object or the standard …
answered Feb 6 '12 by jfriend00
If you have a lot of shared code between the two flavors and only a little different code, then it can be advantageous to have just one function block and use an if statement in the single block. If …
answered Aug 7 '11 by jfriend00
In the second, the function bar() is hoisted to the top of your function block (all functions declared in a block using this syntax are hoisted to the top of the block) and thus exists before you call …
answered Jun 11 '12 by jfriend00
You cannot make client-side javascript private. You can obscure it by running a program that will shorten all the variable names into meaningless names, but by definition if it can be read and executed by a browser, so can it be read by a person. …
answered May 4 '14 by jfriend00
This seems unlikely. The free market is producing some very excellent libraries and those libraries have the advantage that there are no delays through standards bodies and there are NOT multiple some …
answered Aug 13 '12 by jfriend00
My inclination is to always return a promise from a function that must use one to order it's logic. If you have a function with an async operation and you're using promises and there's ever ANY …
answered Jan 9 '16 by jfriend00
The changes it makes vs. regular javascript are pretty well described here. From that reference: Caja takes JavaScript (technically, ECMAScript 5 strict mode code), HTML, and CSS input and … rewrites it into a safe subset of HTML and CSS, plus a single JavaScript function with no free variables. That means the only way such a function can modify an object is if it is given a reference …
answered Mar 29 '12 by jfriend00
symbol in the current scope. Since Javascript doesn't natively require the use of namespaces, it is wise to avoid defining any more global symbols than minimally required. Editorial: It does seem … to have become a cultural thing in Javascript where declaring something anonymously inline is somehow considered "better" than defining a function and calling it even when parent scope access is not …
answered Feb 26 '16 by jfriend00
Since there are only two states and you typically want to follow completely different code paths upon success and error, it seems more useful and clean to reject() if the image does not load. You wil …
answered Mar 24 '16 by jfriend00
The simplest option to have access to both customer and processingResult without nesting would probably be to use async/await (ES7 feature) like this (this would need to be inside an async function de …
answered Jun 25 '18 by jfriend00
There is no "correct" way of doing this as either will work just fine. It depends entirely upon what makes your code the easiest to write, understand and maintain. If I already know the values of o …
answered May 23 '15 by jfriend00

15 30 50 per page