As a mostly self-taught programmer, when I first learned Perl subroutines (like functions in other languages), it was common to write this kind of statement:
sub someFunction(@args) {
(el_1, el2, el3) = @args;
}
I had been doing this procedure for years to essentially explode an array of function arguments into named variables. But, I don't remember it having a name. I just found out yesterday it was called "destructuring". That is a technical, search-friendly term that will get many results when you are researching coding principles.
Another example of a technical, search-friendly term is "nullish coalescing operator". I have no idea what that even is, but it seems like a good example of something a self-taught programmer without a bachelors degree might not automatically know, unless specifically taught it.
In much the same way, I am wanting to know what the technical, search-friendly term for recursively processing or "spidering" a JavaScript object with unknown/variable keys, that has objects or arrays nested on many levels?
WHAT I'VE TRIED:
So far searches like these have been minimally fruitful:
how to parse nested javascript object?
ES6 get properties of json object
spider nested javascript objects with variable unknown keys
One Stack Overflow post that I found promising was this one:
How can I access and process nested objects, arrays or JSON?
Near the very end of user @FelixKling's excellent answer, he describes what I'm talking about, without giving any kind of terminology for it, as thus:
A more generic way to access a nested data structure with unknown keys and depth is to test the type of the value and act accordingly.
Here is an example which adds all primitive values inside a nested data structure into an array (assuming it does not contain any functions). If we encounter an object (or array) we simply call toArray again on that value (recursive call).
function toArray(obj) {
const result = [];
for (const prop in obj) {
const value = obj[prop];
if (typeof value === 'object') {
result.push(toArray(value)); // <- recursive call
}
else {
result.push(value);
}
}
return result;
}