Skip to main content

Questions tagged [underscore.js]

Underscore is a library for JavaScript that provides functional programming support.

Filter by
Sorted by
Tagged with
0 votes
1 answer
78 views

I need to filter projects using a searchbar, it should filter all properties of the projects with a few exceptions. It's working, but it's extremely slow, where can I make optimizations? The "_" is ...
Cold_Class's user avatar
5 votes
5 answers
17k views

NOTE: I'm bringing this question up in code review rather than stack overflow since I already have a working solution. I just am looking for ways to do it better. I have two arrays. One is an array of ...
blueren's user avatar
  • 161
4 votes
1 answer
2k views

Because this is my very first attempt to create a data grid with Vue, I would like to know about all misconceptions used in my approach. Whomever points to the most important shortcoming / weakness in ...
user avatar
2 votes
0 answers
162 views

...
ascendantofrain's user avatar
4 votes
1 answer
120 views

I want to transform such object from: foo = { 42: 'foo', 'a.b.c[0].42': 'bar', 'a.b.c[0].43': 'zet', 'a.d.c[0].42': 'baz' } To: ...
Dmytro Rudnitskikh's user avatar
3 votes
0 answers
476 views

I am working on rewriting the underlying code for some Underscore.js functions. Re-writing the reduce function has been causing a lot of headaches. I have been able to re-write it two different ways, ...
A_A's user avatar
  • 131
2 votes
1 answer
292 views

A made a shipping calculator, which consists of one field that is validated. jsFiddle HTML: ...
cyklop77's user avatar
  • 311
1 vote
1 answer
214 views

I'm using TypeScript but this example is in plain JavaScript. I have a class rank with a child-class master. I need an ordered ...
Иван Грозный's user avatar
1 vote
1 answer
669 views

The code bellow generates all the permutation(with repetitions) for given character set. Is there any better(simpler, more performant) way to do that? ...
kharandziuk's user avatar
1 vote
1 answer
163 views

I've got this kind of data: [ { userId: 1, postId: 1, ... }, { userId: 1, postId: 2, ... }, { userId: 2, postId: 3, ... }, ... ] And I need to group them ...
Yann Bertrand's user avatar
1 vote
1 answer
232 views

I put together a jQuery plugin that displays a month of dates using underscore templates. When the template has been populated and displayed in the UI, a user can click on a date which sends a request ...
Jose the hose's user avatar
4 votes
0 answers
109 views

I have created a Backbone Movie app as part of a learning exercise, the app is hosted on codepen although I actually have it built on my local but thought this approach would be handier for code ...
styler's user avatar
  • 233
4 votes
3 answers
172 views

This question is a follow-up of a previous question of mine: Genetic Drift Simulator. Following the advice given in the last question, and some more general improvements, the code has been slimmed ...
Quill's user avatar
  • 12.1k
7 votes
1 answer
47k views

I have two different arrays: ...
JulieMarie's user avatar
3 votes
1 answer
13k views

I have JSON data: var data = [ { dat: 'timestamp', val: 10 }, { dat: 'timestamp', val: 20}, (...)] Data contains objects with timestamp and value, can be more ...
kxyz's user avatar
  • 131
2 votes
0 answers
79 views

This is horrendous. I'm using lodash's templating engine for this table. Here's the template for an individual record's row. I've got 5 different table and ...
Robin's user avatar
  • 201
4 votes
1 answer
169 views

I currently have what seems to be a very overly complicated underscore template full of conditionals and as the data grows I'm worried the conditions are going to get more and more extreme. Can anyone ...
styler's user avatar
  • 233
3 votes
1 answer
590 views

I have written this function but I am not so proud on it. I could use some help refactoring it. Would recursion improve my code? Data sample. ...
neowinian's user avatar
  • 131
2 votes
2 answers
449 views

In order to perform form validation, I have created a custom object: ...
Trace's user avatar
  • 159
1 vote
3 answers
11k views

I'm sorting my object by its property ActivityOrder, which will sometimes contain null values if the user has not explicitly ...
ZeroBased_IX's user avatar
2 votes
1 answer
934 views

I've built a function that mimics _.throttle (returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per ...
elledienne's user avatar
11 votes
1 answer
2k views

Please look at a small piece of code I wrote and provide some thoughts, critiques and any feedback you think is needed. The code is here along with the problem I have attempted to solve and I look ...
Adam J's user avatar
  • 111
3 votes
1 answer
809 views

I want to improve my code or structure. How does it look? Any comments or suggestions? ...
Shivam Bhalla's user avatar
0 votes
1 answer
106 views

Trying to write more functional Javascript with the underscore library. Any thoughts on how to improve this to be more functional than imperative? Also, any way to do this without ...
dave's user avatar
  • 3
7 votes
2 answers
5k views

Background lodash and underscore have an invert function that takes an object hash and converts it to a new one, which has keys as the input object's values and ...
Ahmed Fasih's user avatar
6 votes
1 answer
4k views

This works, and I personally find it elegant and kind of "neat," but then I worry it's a bit too tricky. Comments welcome: ...
KRyan's user avatar
  • 162
4 votes
1 answer
155 views

I have a small UI that involves adding roles and modules to a user database array. The interface works as is, no problem at all, but it seems to have a bit of 'duplicate' code that I was hoping I ...
ascendantofrain's user avatar
2 votes
1 answer
120 views

I'm new to JS and jQuery. I wrote this function which just does what I want, but it seems very unreadable, and because of my experience, I don't know a better way to handle it. Could you please give ...
Aleksandr K.'s user avatar
2 votes
0 answers
131 views

I'm trying to detect deposits that a user will make. I added explainatory comments inline. Can you spot any flaws in it? ...
Arthur's user avatar
  • 21
7 votes
1 answer
22k views

I've written a method that takes an object whose keys are arrays and converts it to an array of objects. I feel like the code is fairly complex, after waiting a week or so and revisiting it, I don't ...
AlbertEngelB's user avatar
2 votes
1 answer
217 views

From the back-end, I am receiving 8 data. The client requires showing that the row per data is 7, so I have 1 data in balance. I have created empty data and made the empty cells, which works fine. But ...
3gwebtrain's user avatar
4 votes
1 answer
284 views

This code is similar to Underscore. I've added in some functions to fill in different use cases. For example, one can use someKey to iterate through ...
user avatar
2 votes
1 answer
6k views

I have 11 data items and would like to print them as a group. Each group will have header and at the end of the group I need to print continue label. For that, I ...
3gwebtrain's user avatar
0 votes
1 answer
123 views

The code below is converting: data from one format to another ...
kharandziuk's user avatar
6 votes
1 answer
2k views

I wrote a simple JavaScript tool to highlight multiple keywords at the same time in some text. It uses different color for each keyword, and also shows the count of matches. I'm using Backbone.js ...
janos's user avatar
  • 113k
8 votes
1 answer
317 views

I'm working on the interactive API documentation of a RESTful dictionary service. The page should let testers try the different API calls, by playing with the parameters using a simple web form. ...
janos's user avatar
  • 113k
19 votes
2 answers
80k views

Use Case _.pick creates a shallow clone of an object given a predicate that identifies which keys to keep. pickDeep would ...
Pete's user avatar
  • 2,324
0 votes
2 answers
113 views

I have an object, having key and values. I'd like to pick the object and call the appropriate function from the key: ...
3gwebtrain's user avatar
2 votes
3 answers
24k views

Given a hashmap (or a "Dictionary") as a JavaScript object, I'd like to get the Key who has the maximum Value - assuming all Values are integers. In case there's more than one, I don't care which one ...
user40171's user avatar
  • 187
6 votes
1 answer
148 views

I use the jQuery Calendar with an underscore template and I wanted to put <li> tags around each week. This does the trick, but it's awful. ...
kondor's user avatar
  • 163
5 votes
2 answers
3k views

I'd like to add a bulk of items into a sparse array, starting at a certain index. I came along this requirement in order to accomplish client side pagination while not retrieving all data from server (...
user40171's user avatar
  • 187
2 votes
2 answers
8k views

I am sorting 2 arrays of object like this, but I know this is very bad. Any good approach, like using each method like so? ( I tried, but using each, I am unable to return the object ) ...
3gwebtrain's user avatar
0 votes
2 answers
211 views

Compare to underscorejs if it pleases you. Once again, I hope this is well commented. Please let me know what comments/improvements I can add. Please review all aspects of this code. ...
user avatar
2 votes
1 answer
353 views

I made a simple app that fetches the favourite programming language of a Github user, by simply inserting their username. The full code is uploaded on Github, please feel free to fork it from https://...
Elmar's user avatar
  • 21
12 votes
1 answer
784 views

I'm creating an unordered list element in Backbone via Underscore templating: ...
Sean Anderson's user avatar
2 votes
1 answer
182 views

I have inside a Backbone model validate function several if statements: ...
dierre's user avatar
  • 229
5 votes
2 answers
9k views

Could this be better factored as a reduce? ...
Dustin Getz's user avatar
2 votes
2 answers
3k views

I just coded this formatter to format timestamps in javascript (I tied it to underscore for convenience), any remark? ...
David Fregoli's user avatar
1 vote
1 answer
135 views

I'm working on my larger project to date, and on top of that I'm using underscore for the first time. All is working perfectly but I'd like some criticism on the use of underscore templating and ...
David Fregoli's user avatar