Eric Blade
  • Member for 6 years, 11 months
  • Last seen more than 1 year ago
Removing duplicates from an array
0 votes

FWIW, it's pretty easy to do this with newer Javascript: [...new Set(arr)] There are definitely some questions as to the speed of it, though.

View answer
Verify user account on button click with an AJAX call
Accepted answer
4 votes

From: http://api.jquery.com/jquery.ajax/ Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their ...

View answer
A box for comments
Accepted answer
4 votes

I see no particularly compelling reason to make CommentBoxContainer a class instead of a Stateless Functional Component, like most of the rest of the items here. CommentContainer also could be a SFC. ...

View answer
Write log file in nodeJS with setInterval
3 votes

Let the operating system handle write caching for you.

View answer
Find index of an object with a specific value stored in an array
5 votes

I think the best way of doing that would be using the new ES6 function Array.prototype.findIndex: data.findIndex(function(obj) { return obj[where] === what; }) If you don't have that function, there ...

View answer
Star rating: Update stars on click and don't lose the actual vote on re-hover
0 votes

As an item can have both the voted and votable classes, I'd make a specific style for items that have both.

View answer
Widget for collecting leads
2 votes

Using CSS to setup your styles, and just giving items classes would cut this whole thing down to maybe a couple dozen lines. You can even do all your animation with CSS, thereby letting the browser ...

View answer
Changing the background color when a link is clicked
2 votes

I know this isn't doing it "in javascript", but you seriously should take advantage of all native code that you possibly can -- Just do this in CSS. Make them all links, and add a class, such as a....

View answer
Removing duplicates from an array
0 votes

Shortest javascript I can think of to do it: function removeDupes(arr) { var hash = {}; return arr.filter(function(x) { var name = typeof x + x; return !hash[name] && (...

View answer
Notepad5, a simple HTML5, JavaScript notepad webapp
2 votes

using something like this would shorten up your fullscreen stuff... var fullScreen = { request: elem.requestFullScreen || elem.msRequestFullScreen || elem.mozRequestFullScreen || elem....

View answer
Loading 40GB twitter JSON TAR file from archive.org and load into PostgreSQL
1 votes

The best way that I know of to improve throughput when dealing with a large quantity of inserts, is to turn off autocommit, until you are done spooling up all the inserts, and then commit at the end. ...

View answer
Work out if a string is "fieldname" or "tablename.fieldname", and assign variables
2 votes

field = dbFieldEntries.pop(); table = dbFieldEntries.length ? dbFieldEntries[0] : undefined; ... of course, that's working on the assumption that it's only possible to have one or two things ...

View answer