1. Question:What is the function of 'typeof' operator in JavaScript? 

    Answer
    The 'typeof' operator in JavaScript allows us to probe the data type of its operand, such as whether a variable is string, numeric or even undefined or null.

    1. Report
  2. Question:How to use ternary operator in JavaScript? 

    Answer
    The ternary(?) operator can be used as a shortcut for an if....else statement. It is typically used as part of a larger expression where an if...else statement would be awkward. For example:
    var now = new Date();
    var greeting = "Good" + ((now.getHours() > 17) ? " evening." : " day.");
    The example creates a string containing "Good evening." if it is after 6pm.

    1. Report
  3. Question:What is Operator Precedence? 

    Answer
    The order in which expressions are evaluated based on their operators is known as precedence. For example, multiplication and division occur before addition and subtraction, so any operands that are to be multiplied or divided occur before ones that are added and subtracted.

    1. Report
  4. Question:Briefly describe the new, delete and void operators

    Answer
    New operator:All objects must begin with a constructor preceded by the new operator.
    Example:
    var family=new Array("Dad","Mom","Sue","Kris");
    Delete operator:The delete operator removes an object property or an array element in a script. Example:
    var family=new Array("Dad","Mom","Sue","Kris");
    delete family[2];
    Void Operator:Void operator is unary and operates on any literal or variable.Usually, we will see this operator as part of an <A> tag in an HTML script. Example:
    <a href="javascript:void(0)" onClick="scroll(500,0)">

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd