var a=false;
!a&&alert("hi");
Explanation: a is true before execution continues, so hi will pop up
var a=a||"hi";
Explanation When a is false, execution will continue. When a is true, this statement will be jumped out, so you can copy the default value through this method
Not all languages are handled this way, such as PHP
$a= @$a||"hi";
echo $a;//1
php assigns the value after (@$a||"hi")...
$a=true ;
!$a&&echo "hi";
Report error directly: syntax error, unexpected T_ECHO
About prototype
In many cases, when I see prototype, I think of only objects.
var add= function(){alert("b");}
add.prototype.a = function () {alert("hi");}
new add.prototype.a;
First reaction, An error may be reported, but in fact, when there is no production object, you can directly call the static method through add.prototype.a
JS is quite misleading, cough
Selector problem:
Sometimes you need to select the child nodes under a node and use childNodes to get the value FIREFOX. The difference in IE is very frustrating
document.getElementsByTagName("head")[0].getElementsByTagName("script")[0];
The above method works well when used in the head tag stage, but not so useful when used in other areas
I think it’s better to use a class name