These are some of the Very Important Questions that you come across in your Javascript programming life. Javascript interview questions and answers:

1.What is Window SessionStorage?

The sessionStorage stores data for only one session.The data is removed or deleted when the browser is closed. Eg:-//store sessionStorage.setItem("username","Shiva"); //retrieve sessionStorage.getItem("username"); //Shiva

2.What is Window LocalStorage?

The localstorage properties allow to save key/value pairs in a web browser. The important point about localstorage is it stores the data with no expiration date.The data will not be deleted when the browser is closed and it will be available even on next day or next week when you view it on web browser. Eg:-//store localStorage.setItem("username","Muruga"); //retrieve localStorage.getItem("username"); //Muruga

3.What is Json.Parse?

It means interpret or read the data given in the specific format (i.e JSON).So JSON.parse means it reads the string and converts that string to javascript object.The job of the parser is to convert the string into objects.
Let us understand this by this simple example,
var str='{"name": "Shiva"}';
var obj=JSON.parse(str);
before parsing it is a string and you cannot access the data inside it
console.log( // prints "undefined"
after parsing it becomes javascript object and you can access its properties and methods.So you get the name "Shiva" during printing of
console.log( // prints "Shiva"

4. How to get data from server side and display it on client side javascript using $.ajax get?

Scenario: For example, i have 2 files named Example1.aspx and Example2.aspx In example1.aspx i am saving currentdate in session.I need to get the current date in example2.aspx clientside. In example2.aspx, i have button as getcurrentdate.If i click button in example2.aspx,it should go to example1.aspx.cs file where i have stored currentdate in session and return back to example2.aspx. How to achieve? Solution:

        [System.Web.Services.WebMethod(EnableSession = true)]
        [System.Web.Script.Services.ScriptMethod(UseHttpGet = true)]
        public static string GetCurrentDate()
        string ss= HttpContext.Current.Session["hdncurrentdate"].ToString();
        return ss;
        public void SavingDateinSession()
Example2.aspx:- In ajax get request, you cannot pass text as datatype and get data from server (i.e example1.aspx) eventhough it is text data, because default datatype is json for both get and post request.
        <input type="button"  onclick="Fetchcurrentdate()" text=Fetchcurrentdate>
        function Fetchcurrentdate()
        url: '/Example1.aspx/GetCurrentDate',
        type: 'GET',
        async: true,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: '{}',
        success: function (data) {
        currentdate = data.d;
        error: function (xhr) {
        complete: function (data) {