1. 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
  2. Question:What is escape sequence? How to use it? 

    Answer
    Escape sequence is a way to include escape characters and sequences for additional control over string literals. It is written by prefacing a code with a backslash(\). For example, the literal \' prints an apostrophe without affecting the literal itself.






    1. Report
  3. Question:What are Data Types in JavaScript? 

    Answer
    In JavaScript Data types are divided into two basic categories, primitive and compound.Primitive Data Types:Boolean values, numbers, strings, and the null and undefined values all constitute primitive data types.Compound Data Types: Compound data types are made of more than one components. Two primitive data types, such as 10 multiplied by 7, can make up compound data.






    1. Report
  4. Question:What is eval() in javaScript? 

    Answer
    The eval() function evaluates or executes an argument.If the argument is an expression, eval() evaluates the expression. If the argument is one or more JavaScript statements, eval() executes the statements.
    var x = 10;
    var y = 20;
    var a = eval("x*y") + "<br>";
    var b = eval("2+2") + "<br>";
    var c = eval("x+17") + "<br>";
    
    var res = a + b + c;
    The result of res will be 200 4 27






    1. Report
  5. Question:Define concatenation. 

    Answer
    The concatenation is a process to join two or more strings or strings and other literals.Generally '+' is used to concatenate strings.
    For Example:
    var str=("Bangla"+"desh")
    output:Bangladesh






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