Message from JavaScript discussions
December 2017
— You should apply map only on an array not directly on element of array.
From mozilla :
The map() method creates a new array with the results of calling a provided function on every element in the calling array.
— Check if this.data[546] exists first
— Yeah, the thing is, I'm cycling all the elements of my array of objects and I want to store specific values into my array if a certain condition happens.
— But now I'm thinking I could've just pushed them into an array of objects
var arr=[{}];
I think it could work.
— Yeah, it does. :)
— If it did you wouldn't get the error
— Check if it exists in your code I mean
— Is there a more simple solution to this? Use case involves 2 functions, both accept any args (using rest operator) but one has to call the other func...
function someFunc(...args) {
// do something
}
function myFunc(...args) {
someFunc.apply(thisarg, args);
}
— I get I can use rest operator again instead of apply
too, but apply
actually is needed here
— Example real code:
FORK_CHILD: function (bg = false, ...args) {
const pid = this.sysCallProcedures.FORK.call(this, bg, ...args);
this.curProc.childPids.add(pid);
return pid;
},
— That was one of my first thoughts but they're part of the prototype