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


Posted On: Jan 13, 2023


    2 Answers Written

  •  devquora
    Answered by Morgan Garcia

    x=1 has no Variable declared to it

  •  devquora
    Answered 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

Related Questions

Please Login or Register to leave a response.

Related Questions

JavaScript Interview Questions

Explain what is Javascript?

Javascript Javascript is an object-oriented computer programming language commonly used to create interactive effects wi..