Nice, but just a detail. I'd change this line:
(element.hasClass(value)) ? element.removeClass(value) : element.addClass(value);
That structure is a conditional "assignment" not an if statement.
It will be great if you put some explanation of maybe a preview of the prompt
@blainesch you're absolutely right. I didn't thought about that, the alternative image should exist, the idea is to set a default image that you know.
From the documentation http://php.net/manual/en/language.operators.logical.php, is pretty clear how or
and and
work.
Operators like ||
and &&
will make the logical comparison between two boolean values.
$a = false || true; // a => true
is equal to:
$a = (false || true); // a => true
But or
and and
will make a decision in the flow of the program. The or
operator will run the second part of the expression only in the first one has failed. For instance:
connect_to_my_db() or die('Nope!');
That's the most common usage for the or
operator. But, when we use it for something like this:
$a = false or true; // a => false
This is the wrong way to use this kind of operator. What happens here is that, PHP will try to identify two expressions and it will do it. The first expression is $a = false
and the second one is true
. Then will consider that the assignment was successful and will not use the second part of the or
operation.
So, the equivalent for the previous line of PHP is:
($a = false) or true; // $a => false
The same thing for the and
operator, but it'll examine the second part of the operation only in the first one was successful. For example, you can do something like this:
open_my_file() and read_my_file();
Only if the opening of the file has succeeded then it'll read the content of the file.
Is this confusing? Maybe yes. So, this is not a bug, but we're using the language in the wrong way.
@creaktive that's a great link, every PHP developer must read. But is not related to this tip.
For me, one of the major achievements of "border-box method" is the safe use of mixed units; i.e. width of 50% and border of 1px.
Also, var_dump shows information about the type of the variable. I think that each of them is for a particular purpose.
I'll start to use it.
Hey, nice resource!
Thanks
Great tip. I think that I'm gonna use it a lot.
PS: The next time be more verbose please :P
The bug is already fixed.
This was very useful for me.