What is difference between var x =1; and x=1;?

Sharad Jaiswal
Written by Sharad Jaiswal

Posted On: Oct 07, 2018


    2 Answers Written

  •  Sharad Jaiswal
    Posted by Morgan Garcia

    x=1 has no Variable declared to it

  •  Sharad Jaiswal
    Posted by Raj Kumar

    var x =1;
    When a variable declared with keyword 'var' its scope is functional scope.


    when a variable is declared like above then its scope is global. This variable is available to user as 'window.x' . That means it is available in global object of javascript

Please Login or Register to leave a response.

Related Questions

Ask a Question