js in some weird wording

Original link: http://www.cnblogs.com/janey/archive/2010/01/08/1642566.html

1, var s = (1 == 0) || {name: 'janey'}
   because 1 == 0 is false, or in accordance with the rules of operation, operation continues to give {name: 'janey'}, so s = {name : 'janey'}
   Similarly var s = (1 == 1) || {name: 'janey'}, case 1 == 1 is true, go no further operation, so s = true;
   results ORed not directly equal to true or false, but may be determined that a first value of true;
   var S = (|| 0 || 2 [1,2]), Boolean operation value 0 is false, so continue, 2 the calculated value of the boolean true, the operation is stopped, and the assignment to s 2
   had seen many if (a || B expression expression), or that the calculation result is directly or false true, greatly misunderstood
   && operator result is in this way

2, if (judging expression) {statement A ;} (statement B) // I did not find out the current
   statement B are executed sequentially, but why is unclear bracketed
   say is that A contains the return statement will complain: return not in function
   EG: IF (0) {return} (Alert ( 'Hello World'));
   write will be reported in return not in function wrong solution is a sentence written in the function as follows:
   (function () {if (1) {var i = 5; alert ( 'i');} (alert ( 'hello janey'))}) ();
   Why do not know

Reproduced in: https: //www.cnblogs.com/janey/archive/2010/01/08/1642566.html

Guess you like

Origin blog.csdn.net/weixin_30672019/article/details/95049417