1. Question:What is the difference between setInterval and setTimeout? 

    Answer
    setInterval: The setInterval() method repeats a script action every so many milliseconds. initiating  the script after the specified number of milliseconds.
    
    setTimeout: The setTimeout() method  works the same as setInterval(), except that it does not repeat the script.

    1. Report
  2. Question:What is the function charAt() 

    Answer
    The charAt() method returns the character at the specified index in a string.
    
    The index of the first character is 0, the second character is 1, and so on.
    Example:
    var character=new String("Bangladesh");
     character=character.charAt(5);
    document.write(character);
    output:'a'.

    1. Report
  3. Question:What is the function of indexOf()? 

    Answer
    The indexOf() method returns the position of the first occurrence of a specified value in a string. This method returns- 1 if the value which is searched never occurs.
    Example:
    var str="Hello world, welcome to Bangladesh."
    var ind=str.indexOf("welcome");
    Output:13

    1. Report
  4. Question:What is the difference between substring() and substr()? 

    Answer
    Both substring() and substr() functions are used to extract a fragment of a string but  they perform the task in a different way. such as substring() enters the beginning and ending numeric positions of a part of the string to  extract, whereas the substr() specifies the position of the first character of the string  and number of characters to extract.
    Example:
    1.var str="Bangladesh";
    var res=str.substring(6,10);
    The result of res will be 'desh'.
    2.var st="JavaScript"; 
    var res=str.substr(4,6);
    The result of res will be 'Script'.

    1. Report
  5. Question:What do you mean by objects? write 5 built in objects in JavaScript. 

    Answer
    Object: Objects are collection of properties in a hierarchy.
    Five built-in objects in JavaScript:
    1.Window.prompt()
    2.window.alert()
    3.Math.floor()
    4.Math.max()
    5.document.write()

    1. Report
  6. Question:What is the function of floor(), ceil() and round() methods of Math object? 

    Answer
    Math.round(): The round() method of Math Objects rounds the numeric data to the nearest integer.
    Math.floor(): The floor() method of Math objects returns the input data, rounded downwards to the nearest integer.
    Math.ceil(): The ceil() method of Math objects returns the input data, rounded upwards to the nearest integer.

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