Message from JavaScript discussions

May 2017

— Keep in mind:
simple values (boolean, strings, numbers) are pass-by-value in JS, so they get copied into functions
whereas complex values (arrays, objects, functions) are pass-by-reference, so the functions get access to the outer value

Message permanent page


function modifySimple(val) {
val += 1;

function modifyObject(obj) {
obj.prop = 'Hello';

let val = 2;
// still 2

let obj = {};
// now: { prop: 'Hello' }

— Floofies I need to traverse an object, then traverse back up to the root, would you use an array to store a reference to each parent object?

Message permanent page

— Or some other structure?

— I already know the keys to traverse down by

— A stack, yes

— Push and pop, right?

— Correct

— Good, good

— You can maintain a "current path" using that ordered set

— In IDDFS it represents a list of nodes to be traversed into

— And not the path