What does this code do: [code]
- User
What does this code do:
javascriptexport default function set(obj, path, value) { if (!Array.isArray(path)) throw new Error('Not an array'); if (path.length === 0) return value; if (obj === null || obj === undefined) { obj = {}; // eslint-disable-line no-param-reassign } if (typeof obj !== 'object') { // eslint-disable-next-line no-console console.error(`Cannot set property ${JSON.stringify(path)} of ${typeof obj} ${obj}`); } const [propName, ...subpath] = path; const res = clone(obj); res[propName] = set(obj[propName], subpath, value); return res; } Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.