Javascript code semantics

Posted by Mohammad on Stack Overflow See other posts from Stack Overflow or by Mohammad
Published on 2010-05-29T21:41:34Z Indexed on 2010/05/29 21:52 UTC
Read the original article Hit count: 205

Filed under:
if(myVar = img.parent('a').length > 0){
    var Y = 1;
    var Y = 2;

When I run this code myVar (being announced for the first time) takes the value of img.parent('a').length > 0 and becomes either false or true depending on the case.

First Question:
Is this a correct way of defining myVar?

Second Question:
Am I defining Y for the second time? Is my second 'var' excess?
i.e. should i just write Y = 2;

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about semantics