registration
Are you an Employer?

Javascript Advanced interview questions & Answers

Javascript Advanced Related links

List of Topics

Javascript Advanced Interview questions

  • What Is The Difference Between Undefined And Not Defined In Javascript?

    In JavaScript, if you try to use a variable that doesn't exist and has not been declared, then JavaScript will throw an error var name is not defined and script will stop executing. However, if you use typeof undeclared_variable, then it will return undefined.

    Before getting further into this, let's first understand the difference between declaration and definition.

    Let's say var x is a declaration because you have not defined what value it holds yet, but you have declared its existence and the need for memory allocation.

    > var x; // declaring x
    > console.log(x); //output: undefined 

    Here var x = 1 is both a declaration and definition (also we can say we are doing an initialisation). In the example above, the declaration and assignment of value happen inline for variable x. In JavaScript, every variable or function declaration you bring to the top of its current scope is called hoisting.

    The assignment happens in order, so when we try to access a variable that is declared but not defined yet, we will get the result undefined.

    var x; // Declaration
    if(typeof x === 'undefined') // Will return true

    If a variable that is neither declared nor defined, when we try to reference such a variable we'd get the result not defined.

    > console.log(y);  // Output: ReferenceError: y is not defined

  • What Will Be The Output Of The Code Below?
    var Y = 1;
    if (function F(){})
    {
    y += Typeof F;
    }
    console.log(y);

  • What Is The Drawback Of Creating True Private Methods In Javascript?

  • What Is A “closure” In Javascript? Provide An Example

  • Write A Mul Function Which Will Produce The Following Outputs When Invoked?

  • How To Empty An Array In Javascript?

  • How Do You Check If An Object Is An Array Or Not?

  • What Will Be The Output Of The Following Code?
    var Output = (function(x)
    {    
    Delete X;    
    return X;  
    }
    )(0);
    console.log(output);

  • What Will Be The Output Of The Following Code?
    var X = 1;
    var Output = (function()
    {    
    Delete X;    
    Return X;
      }
    )();
     console.log(output);

  • What Will Be The Output Of The Code Below?
    var X = { Foo : 1};
    var Output = (function()
    {
    delete X.foo;
    return X.foo;
    }
    )();
    console.log(output);

  • What Will Be The Output Of The Code Below?
    var Employee =
    {
    company: 'xyz'
    }
    var Emp1 = Object.create(employee);
    delete Emp1.company Console.log(emp1.company);

  • What Is Undefined X 1 In Javascript?

  • What Will Be The Output Of The Code Below?
    var Trees = ["xyz","xxxx","test","ryan","apple"];
    delete Trees[3];
    console.log(trees.length);

  • If We Have A Javascript Associative Array
    Var Counterarray =
    {
    A : 3,
    b : 4
    };
    Counterarray["c"] = 1;
    how Can We Calculate The Length Of The Above Associative Array's Counter Array?

  • What Is The Instanceof Operator In Javascript? What Would Be The Output Of The Code Below?
    function Foo()
    {
    return Foo;
    }
    new Foo() Instanceof Foo;

  • What Will Be The Output Of Code Below?
    var Salary = "1000$";
    (function ()
    {
    console.log("original Salary Was " + Salary);
    var Salary = "5000$";
    Console.log("my New Salary " + Salary);
    }
    )();

  • What Is Function Hoisting In Javascript?
    function Expression
     var Foo = Function Foo()
    {   
    return 12; 
     }; 

  • What Is The Difference Between The Function Declarations Below?
     var Foo = Function(){ 
      // Some Code
     }; 
      Function Bar(){ 
      // Some Code
     }; 

  • What Will Be The Output Of The Code Below?
     // Nfe (named Function Expression 
     var Foo = Function Bar()
    {
    return 12;
    };
     typeof Bar();  

  • What Will Be The Output Of The Code Below?
    var Z = 1, Y = Z = Typeof Y;
    console.log(y);

  • What Will Be The Output Of The Code Below?
    var Bar = True;
    console.log(bar + 0);
    console.log(bar + "xyz");
    console.log(bar + True);
    console.log(bar + False);

 

Top