JavaScript global boolean Variable convert itself to string -


first i'm new javascript, please don't hate me if ask such trivial question.

i've searched hours on google, cannot find solution problem. have declared global variable "status", false. if check datatype within function, says "string", allways true, script doens't work @ all.

var status = false;    function slide(element) {      if (status) {          slideup(element);      } else {          slidedown(element);      }  }    function slidedown(element) {      status = true;      // testprint todo remove      alert('status ' + status + ' , type: ' + typeof status);      // todo  }    function slideup(element) {      status = false;      // testprint todo remove      alert('status ' + status + ' , type: ' + typeof status);      // todo  }

am wrong or have write myself function convert every time boolean var "real" boolean var? have tested myself , show me boolean datatype...

this works fine...

var test = false;  mytestfunc();    mytestfunc() {      if(!test) {        test = true;        alert('test false');      } else {        test = false;        alert('test true');      }            alert('test contains: ' + test + ' , has type: ' + typeof test);  }

i see, javascript seems randomly declare variables. there solution make variable boolean datatype?

better there chance force initialation boolean int varname?

the problem window.status - see https://developer.mozilla.org/en-us/docs/web/api/window/status

change name (or scope) of var , it's sweet


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -