5,737 questions
0
votes
0
answers
153
views
Conflict between lodash.js and underscore.js
I am working on integrating a plugin into my application which resulted in lodash.js and underscore.js conflict. I have underscore.js implemented in my entire application and this plugin which I am ...
1
vote
2
answers
51
views
Sort Backbone Collection based on a file order list
I have a inherited a system that utilizes a Backbone collection of files that needs to be sorted based on a series of values. The order variable is saved when you slide different files into a position ...
1
vote
0
answers
38
views
Uncaught TypeError: App.Routers.Maintenances.MyRouter is not a constructor
I am using backbone js as frontend in rails 7 application. In index.html file I have called backbone main file. code is coming in this file. But here I have initialise router file. In which getting ...
0
votes
0
answers
33
views
Why _.clone() doesn't copy object methods?
I use the underscore library to copy objects, the _.clone() method. And this method works differently on different versions of angular, or maybe the problem is something else?
F.e:
class FooBar {
...
0
votes
1
answer
344
views
Returning the last computed result in a throttled function
I am working on a exercise based of the underscore _.throttle function. Our function is slightly modified as we have the return the last computed result if the _.throttle function is still waiting to ...
0
votes
1
answer
61
views
_lodash, sort by 2 fields(numbers, time)
I have an array of object with data:
items = [
{
....someFields
timeFrom: {
hour: 17,
minute: 15
}
},
{
....someFields
timeFrom: {
hour: 12,
...
0
votes
1
answer
35
views
How to chain Underscore methods to populate an object from nested array?
I have an array of objects - say, NFL teams. Each object (team) has a property - array of first names of team players.
var nflTeams = [
{ name: 'Kansas City Chiefs', playersFirstNames: ['Shane', ...
0
votes
3
answers
89
views
Javascript find objects that contain matching elements from arrays in another object
I have two objects:
const people = [
{
name: "Dave",
fruit: ["apple", "pear"],
veg: ["asparagus", "peas"]
},
{
name: "Frank",...
1
vote
2
answers
36
views
how to group nested obects using underscorejs and get the matching data length
How to group the matching data in array of object and get the matching data length to get the average value.
var getdataObj = [{
"finalUrl": "https://www.amazon.in/",
"fetchTime": "2022-10-...
1
vote
1
answer
83
views
Jupyter Notebook - underscore.js doesn't seem to be accessible anymore
I'm using a custom widget in Jupyter. After upgrading to a new machine it stopped functioning. Checking the javascript console in the browser window running the notebook I see the error ReferenceError:...
1
vote
2
answers
137
views
Remove key value pair from an object in javascript using underscoreJs
I have an array
var data = {email: '[email protected]', phone: '3434344332', firstName: 'john', lastName: 'Doe'};
How do i remove one or more elements from the array?
I Tried _.without( data, data....
0
votes
4
answers
202
views
How to get an object containing the sum of all items in an arrays of objects?
I have an array of objects where each index is one week where I bought groceries. Meaning that array[0] is the first week, array[1] is the second and the so on. What I need to do is do sum all the ...
2
votes
1
answer
747
views
Confused about lodash merge in this case
I understand how a simple lodash merge works but as I was playing around with it to try more complicated scenarios I got confused about how the output is being formed for instance:
const a = [{ h: 1, ...
0
votes
1
answer
63
views
How can i remove the object in the array if 2 properties of array objects are equal? [duplicate]
I have a situation where i need to find the duplicate element in array of object. Object contains 4 properties
{
id:"1",
userName:"userName",
name:"name1",
address:"...
1
vote
3
answers
152
views
how to use underscore .reduce to return and object that counts properties
considering
var desserts = [
{
name: 'Chocolate Cake',
ingredients: ['cocoa', 'flour', 'sugar', 'eggs', 'milk', 'butter' ],
type: 'cake'
},
{
name: 'Snickerdoodles',
...
1
vote
2
answers
544
views
how to resolve not found type declarations error while using Underscore with typescript
I try to use the modular import from the underscore in a typescript app like this:
import map from 'underscore/modules/map'
It works and does the job, but cause the below error:
Cannot find module '...
0
votes
2
answers
158
views
Return an array with the result of calling a method from underscore
I'm trying to recreate the functionality of the underscore _.invoke for learning purposes and I would like to really understand how it works as it seems to be something not too complicated.
The ...
0
votes
3
answers
57
views
Return all values of nested arrays using string identifier
Given an object searchable, is there a simple way of returning all the id values using lodash or underscore.js (or equivalent) where I can define the path to id?
const searchable = {
things: [
...
0
votes
1
answer
296
views
Cannot pass arguments in the invoke function I recreated
I am trying to recreate .invoke() function.
I am able to call the function, but struggling with passing the arguments. I tried using call and apply, but couldn't make it work.
Here is my code:
_....
-1
votes
1
answer
115
views
I was try to solve Python program to create Fibonacci series using Lambda, but I unable to solve it
So on internet they solve using:
from functools import reduce
fib = lambda n: reduce(lambda x, _: x+[x[-1]+x[-2]],range(n-2), [0, 1])
print(fib(5))
Fibonacci program
I don't understand what's the ...
1
vote
1
answer
644
views
Security issues in neb and underscore
this is my first question and I hope I am not coming up with something totally stupid.
I am new to JS and Node.js. I can solve easy issues on my own, but with this pollution report I need some advice.
...
1
vote
2
answers
654
views
Underscore's debounce seemingly not taking effect with function calling an async function
I have some ionic segment buttons that essentially act as toggle switches. I'm trying to limit the rate at which the effects of the toggles can be switched/selected) and have tried Debounce & ...
2
votes
3
answers
4k
views
Search a deeply nested array to update an object
I have a deeply nested data structure and I am interested in matching a certain value inside my array (and array of arrays) and then pushing some data inside an accompanying array. For example ...
3
votes
1
answer
5k
views
SyntaxError: Unexpected token 'export' Underscore.js
I'm getting this error when I copy-paste the underscore.js to my console. Error screenshot "Uncaught SyntaxError; Unexpected token 'export'"
I tried on both Chrome Version 100.0.4896.127 and ...
1
vote
1
answer
346
views
Underscore "defaults" from scratch
I've been trying to rewrite the _.defaults method from underscore.js and I keep getting this error:
should copy source properties to undefined properties in the destination object‣
AssertionError: ...