1.
Which of the following is correct about the features of JavaScript?
Correct Answer
C. Both of the above.
Explanation
The correct answer is "Both of the above." This means that both statements mentioned in the options are correct about the features of JavaScript. JavaScript is indeed complementary to and integrated with HTML, meaning it can be used to enhance the functionality and interactivity of web pages. Additionally, JavaScript is open and cross-platform, meaning it can be run on different operating systems and devices.
2.
How can you get the type of arguments passed to a function?
Correct Answer
A. Using typeof operator
Explanation
The typeof operator can be used to determine the type of arguments passed to a function. This operator returns a string indicating the type of the operand. Therefore, using the typeof operator is the correct way to get the type of arguments passed to a function.
3.
Which built-in method returns the character at the specified index?
Correct Answer
C. CharAt()
Explanation
The correct answer is charAt(). This is because the charAt() method is a built-in method in many programming languages, including Java and JavaScript, that returns the character at the specified index in a string. It is commonly used to access individual characters within a string by providing the index as a parameter.
4.
Which built-in method returns the string representation of the number's value?
Correct Answer
C. ToString()
Explanation
The toString() method is a built-in method in JavaScript that returns the string representation of a number's value. It converts a number to a string and allows for easy manipulation and concatenation with other strings. This method is commonly used when working with numbers in JavaScript and is the correct answer to the question.
5.
Which of the following function of the String object returns a number indicating the Unicode value of the character at the given index?
Correct Answer
B. CharCodeAt()
Explanation
The function charCodeAt() is used to return the Unicode value of the character at a specific index within a string. It takes the index as a parameter and returns the Unicode value as a number. This function is useful when working with international characters or when comparing characters based on their Unicode values. The other options, such as charAt(), concat(), and indexOf(), do not specifically return the Unicode value of a character at a given index.
6.
Which of the following function of the String object returns the index within the calling String object of the last occurrence of the specified value?
Correct Answer
A. LastIndexOf()
Explanation
The function lastIndexOf() is the correct answer because it returns the index of the last occurrence of a specified value within a string. This function searches the string from the end to the beginning and returns the index of the last occurrence found. This is useful when you want to find the position of the last occurrence of a character or substring within a string.
7.
Which of the following function of the String object creates a string to be displayed in a big font as if it were in a <big> tag?
Correct Answer
B. Big()
Explanation
The big() function of the String object creates a string to be displayed in a big font as if it were in a tag. This function is used to increase the font size of the text and make it appear larger.
8.
Which of the following function of the String object causes a string to be displayed as a subscript as if it were in a <sub> tag?
Correct Answer
D. Sub()
Explanation
The sub() function of the String object causes a string to be displayed as a subscript as if it were in a tag. This is useful when we want to display text in a smaller size and lower position, typically used for mathematical or chemical formulas, footnotes, or abbreviations.
9.
Which of the following function of Array object returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found?
Correct Answer
A. IndexOf()
Explanation
The indexOf() function of the Array object returns the first index of an element within the array that is equal to the specified value. If no element is found, it returns -1. This function is useful for finding the position of a specific element in an array.
10.
Which of the following function of the Array object returns a string representing the array and its elements?
Correct Answer
D. ToString()
Explanation
The toString() function of the Array object returns a string representing the array and its elements. This function converts each element of the array to a string and then concatenates them together, separated by commas. The resulting string is then returned. This is useful when we want to display the contents of an array as a single string.