Search Results
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) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
JavaScript is a versatile, high-level programming language. It is the programming language in all browsers.and can be used for back-end programming with node.js. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.
29
votes
Drawing a grid on canvas
Try using a SVG object on the canvas:
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="smallGrid" width="8" height="8" patternUnits="userSpaceOnUse" …
22
votes
Accepted
Rock, Paper, Scissors, Lizard and Spock
To review the code as it is:
It would be better not to even have result as a variable, and swap the order of operations inside the else-ifs that assign result from (result = X, gameResult++) to (gam …
17
votes
You hate h̶a̶t̶s̶ reputation? Click here to get rid of it
Update url
UserScripts have the magical ability to update themselves if you provide a link to a raw version of your script as a UserScript header:
Note: You actually have to increase the version, or …
14
votes
Accepted
A simple JavaScript library for arrays
Description:
Library: Omega.js - Ω.js - A utility library for JavaScript programs. :)
A utility library for JavaScript programs is a bit... confusing, consider alternatives like: A utility library … for JavaScript scripts/JavaScript functions or something similar. …
13
votes
Arabic to Greek numeral converter, 1 - 10
Reviewing your current structure: your return ""; could be improved: it should / could be inside the switch statement as a default case.
It's better to use an object here, as later you can extend i …
11
votes
"Star Catcher" game
Making your variables & functions public
For games like this, it's better to have the JavaScript stored in an external file and minified/obfuscated. …
10
votes
Image Filter client
defaultOptions:
Providing a defaultOptions array is useless if you don't use any other property than imageCallback
The following line is redundant if you wish to create imageCallback and not an empt …
8
votes
HTML to Markdown converter
A few things to point out:
ul: function(data) {
var lis = childnodes[data.i].childNodes;
var newmd = '';
var lislength = lis.length;
for (var x = 0; x < lislength; x++) {
n …
7
votes
Accepted
Saving data in local storage
Structure:
Instead of having a function encompass everything, consider using a prototype constructor, or if you can use ECMAScript 2015, use the class structure.
By using the prototype structure you …
7
votes
Stack Exchange Post Reminder
What I also saw is that the jQuery you have could be replaced with vanilla JavaScript equivalents, meaning you could chop the library entirely out of your code. …
7
votes
Stack Exchange Chat Caret Pathfinder
One line variable declaration
Please avoid declaring variables on the same line:
var elements = {}, messages;
It's also a great way to royally mess up scope issues if you do it on two lines but …
7
votes
Accepted
Prorated Refund Calculator (v2)
I'm not familiar with the level of JavaScript expertise your colleagues have, but, this code is well written, the code is consistent, and it contains descriptive @params and @returns. Good Work! …
7
votes
Accepted
Desktop notifications for queue items
This is mostly personal preference, but, I usually stack the @matches in descending size:
// @match *://*.stackexchange.com/review*
// @match *://*.stackoverflow.com/review*
// @match *://*.superus …
7
votes
Accepted
The Handy-Dandy Apocalypse Assistant
There's a few things you can improve.
UserScripts should follow the *.user.js format, so that TamperMonkey, GreaseMonkey, GoogleChrome and the other installers can pick up on the fact that it's a U …
7
votes
Accepted
Hot Post-ato Guessing Game
Button adding:
var button = createTopbarButton();
var topbar = document.getElementsByClassName("topbar-menu-links")[0];
topbar.appendChild(button);
Why not bundle this all in createTopbarButton?
…