- Notifications
You must be signed in to change notification settings - Fork5
setPath$
Subhajit Sahu edited this pageMay 3, 2023 ·9 revisions
Set value at path in a nested array!
Alternatives:set,set$,setPath$.
Similar:hasPath,getPath,setPath$,removePath$.
Similar:get,set,remove.
functionsetPath$(x,p,v)// x: a nested array (updated!)// p: path// v: value
constxarray=require('extra-array');varx=[[2,4],6,8];xarray.setPath$(x,[1],60);// → [ [ 2, 4 ], 60, 8 ]x;// → [ [ 2, 4 ], 60, 8 ]xarray.setPath$(x,[0,1],40);// → [ [ 2, 40 ], 60, 8 ]xarray.setPath$(x,[0,1,2],100);// → [ [ 2, 40 ], 60, 8 ] (path not present, no effect)