javascript - Can you use = and == together in the same script? -


had problems script running, built around dropdown menus. single equals = , equals == both used in same function, though not same if statement. not see else amiss , made uses ==, seemed resolve problem. i'm relatively new javascript, wondering if combining different styles of equals makes difference all. didn't think did.

your question doesn't make sense - these different operators. in javascript:

= assignment operator, e.g.  var x = 1;  if (x = 1) // not compare x 1, assign value 1 x            // , return value if block decide            // whether value truthy or not (and in case             // return true).  == comparison operator, e.g.  var x == 1;  //this not make sense (or run)  if (x == 1) {   === comparison , ensures both operands same type:  var x = "1";  if (x == 1) { //returns true  if (x === 1) //returns false. 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -