Hey guys,

According to Javascript's Operator Precedence, we know that grouping
comes before logical OR. So, for the following snippet I expect line 2
to be evaluated as follows:

1) first, the statement within parenthesis, gets evaluated and hence
myVar will be set to 'Hello there'
2) the logical or is then examined (from left to right, of course). As
the first argument is non-false, the whole statement will be evaluated
to myVar, which has formerly been set to 'Hello there'

so I expect console.log to print out  'Hello there' but it doesn't,
why?

/*------------------------------------------*/
1. var myVar = 'test';
2. console.log(myVar || (myVar = 'Hello there'))
/*------------------------------------------*/


Reference: http://msdn.microsoft.com/en-us/library/z3ks45k7(v=vs.94).aspx

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to