QIII!
Thanks, again.
iMac71!
Thanks for your test scenario. I hear you.
With your lessons in mind (and via jsbin's lab)...
Code:
var a=[4,5,6,7,8,9];
var b=[0,4,8,12,16,20];
xC=a.slice(0,1);
xD=a.slice(0,1);
y=b.indexOf(xC);
y1=b.indexOf(xC[0]);
z=b[xC];
z1=b[xC[0]];
document.write("xC=array <i>"+typeof(xC)+"</i> <b>xC</b> contains <i>"+typeof(xC[0])+"</i>(s) <b>"+xC+"</b> from array <i>"+typeof(a)+"</i> <b>a</b><br>");
document.write("xD=array <i>"+typeof(xD)+"</i> <b>xD</b> contains <i>"+typeof(xD[0])+"</i>(s) <b>"+xD+"</b> from array <i>"+typeof(a)+"</i> <b>a</b><br>");
document.write("<br>");
document.write("y=the indexOf array <i>"+typeof(xC)+"</i> <b>xC</b> in array <i>"+typeof(b)+"</i> <b>b</b> is <b>"+y+"</b><br>");
document.write("y1=the indexOf <i>"+typeof(xC[0])+"</i> <b>"+xC+"</b> in array <i>"+typeof(b)+"</i> <b>b</b> is <b>"+y1+"</b><br>");
document.write("<br>");
document.write("z=the <i>"+typeof(z)+"</i> <b>"+z+"</b> is in position "+xC+" in array <i>"+typeof(b)+"</i> <b>b</b><br>");
document.write("z1=the <i>"+typeof(z1)+"</i> <b>"+z1+"</b> is in position "+xC[0]+" in array <i>"+typeof(b)+"</i> <b>b</b><br>");
document.write("<br>");
document.write("Should the result of \"(xC===xD)\" be <b>"+(xC===xD)+"</b>?<br>");
document.write("<br>");
document.write(xC+"<br>");
document.write(xD+"<br>");
...these questions emerge:
1. for y, why is xC treated as an object, whereas for z, xC seems to resolve to the number 4?
2. for y1 (and z1), it seems treating xC as an object with [reference] to a specific element allows xC to be evaluated by indexOf.
3. xC===xD is still false, should this be so? Perhaps, yes? See the bottom of this page.
4. xC and xD BOTH resolve to the number (?) 4 via document.write().
Thanks, again, for your help!
Bookmarks