ID:156129
 
So, my understanding is using && implies both values are TRUE, and & means both values are DEFINED, but may be FALSE? Is this true? I can't seem to find much of a difference between the two.

Also, another question. Javascript is client-sided, so naturally would perform quicker, correct?
& is the binary AND operator.
 1001 //9
&1000 //8
-----
1000 //8

1111 //15
&0011 //3
-----
0001 //3

&& is the boolean AND operator
if(cake>0 && pie==3)


CauTi0N wrote:
So, my understanding is using && implies both values are TRUE, and & means both values are DEFINED, but may be FALSE? Is this true? I can't seem to find much of a difference between the two.

The & operator is a binary AND. It takes two numerical values and returns a number where the only bits left "on" are the ones that were on in both original numbers. You can also use this on lists, in which case it returns a list that has only items that were common to both original lists.

The && operator is a conditional AND. Its purpose is to quickly give you true and false values in an if() or while() statement, but it can be used elsewhere. The value of the expression will be the first false value found, or the last true value found. This also short-cuts, which means that if the left side of the operator is a false expression, the right side is not evaluated.

As an example, 1 & 4 is 0 which is a false value, but 1 && 4 is 4.

Also, another question. Javascript is client-sided, so naturally would perform quicker, correct?

That's not necessarily the case, but it might be useful for doing some calculations if you can get JS to talk to the server again.

Lummox JR
In response to Lummox JR
Good to note. Would Javascript's internal sort() be a quicker solution for alphabetization than writing one in DM? I wrote one that works, but takes ages if I input anything over roughly 1000+ words.