Javascript: Create a 10x10 array of 1s
Javascript, 34 bytes
for(r=[b=[i=10]];i--;r[i]=b)b[i]=1
Since it's apparently OK to make the rows equal by reference, I guess it's apparently OK to rely on that fact. This helps us shave off one for-loop by building the table at the same time as its rows. So, here's my new contestant.
Since r[0]
and b[0]
are overwritten during the loop, they can contain garbage. This gives us another free execution slot to shave off some commas. Sadly, r=b=[]
won't do, since then they are equal by-ref.
Also, it scales well (99x99 is still 34 bytes), doesn't require ES5 (the new functions have terribly long names, anyways), and as a bonus, it's unreadable :-)
ECMAScript 6 - 33 Characters
x=(y=[..."1111111111"]).map(x=>y)
Outputs a 10x10 array of "1"s.
This abuses the fact that the string "1111111111" has all the requisite properties to be treated as if it is an array so you can use the spread operator ...
to transform it into an array of characters and then map it to a copy of the array with each element referencing the "original".
Or with only one variable name (for 35 characters):
x=(x=x=>[..."1111111111"])().map(x)
Or for extra confusion (but at 45 characters)
x=[];x[9]=x;x=[...x].map(y=>[...x].map(x=>1))
or (43 characters)
y=y=>[...x].map(x=>y);x=[];x[9]=x;x=y(y(1))
44 bytes
for(a=[i=10];i;)a[--i]=[1,1,1,1,1,1,1,1,1,1]
Previous version:
for(a=i=[];i^10;)a[i++]=[1,1,1,1,1,1,1,1,1,1]