The function which has named at the time of definition is called a named function. For example
7) Name the types of functions
The types of function are:
8) Define anonymous function
It is a function that has no name. These functions are declared dynamically at runtime using the function operator instead of the function declaration. The function operator is more flexible than a function declaration. It can be easily used in the place of an expression. For example:
9) Can an anonymous function be assigned to a variable?
Yes, you can assign an anonymous function to a variable.
11) Define closure.
12) If we want to return the character from a specific index which method is used?
I am assuming that js file name is message.js, place the following script tag inside the head tag.More details.
18) What is BOM?
BOM stands for Browser Object Model. It provides interaction with the browser. The default object of a browser is a window. So, you can call all the functions of the window by specifying the window or directly. The window object provides various properties like document, history, screen, navigator, location, innerHeight, innerWidth,More Details: Browser Object Model
19) What is DOM? What is the use of document object?
DOM stands for Document Object Model. A document object represents the HTML document. It can be used to access and change the content of HTML.More Details: Document Object Model
20) What is the use of window object?
The window object is used to display the popup dialog box. Let's see with description.
21) What is the use of history object?
The history object of a browser can be used to switch to history pages such as back and forward from the current page or another page. There are three methods of history object.
Primitive data types
The primitive data types are as follows:
String: The string data type represents a sequence of characters. It is written within quotes and can be represented using a single or a double quote.
Number: The number data type is used to represent numeric values and can be written with or without decimals.
Boolean: The Boolean data type is used to represent a Boolean value, either false or true. This data type is generally used for conditional testing.
BigInt: The BigInt data type is used to store numbers beyond the Number data type limitation. This data type can store large integers and is represented by adding "n" to an integer literal.
Undefined: The Undefined data type is used when a variable is declared but not assigned. The value of this data type is undefined, and its type is also undefined.
Null: The Null data type is used to represent a non-existent, null, or a invalid value i.e. no value at all.
typeof: The typeof operator is used to determine what type of data a variable or operand contains. It can be used with or without parentheses (typeof(x) or typeof x). This is mainly used in situations when you need to process the values of different types.
Non-Primitive data types
In the above examples, we can see that the primitive data types can store only a single value. To store multiple and complex values, we have to use non-primitive data types.
The non-primitive data types are as follows:
Object: The Object is a non-primitive data type. It is used to store collections of data. An object contains properties, defined as a key-value pair. A property key (name) is always a string, but the value can be any data type, such as strings, numbers, Booleans, or complex data types like arrays, functions, and other objects.
Array: The Array data type is used to represent a group of similar values. Every value in an array has a numeric position, called its index, and it may contain data of any data type-numbers, strings, Booleans, functions, objects, and even other arrays. The array index starts from 0 so that the first array element is arr, not arr.
25) What is the difference between == and ===?
The == operator checks equality only whereas === checks equality, and data type, i.e., a value must be of the same type.
Let's see a simple code to create an object using object literal.More details.
Let's see a simple code to create an array using object literal.More details.
30) What does the isNaN() function?
The isNan() function returns true if the variable value is not a number. For example:
3030 because 10+20 will be 30. If there is numeric value before and after +, it treats as binary + (arithmetic operator).
102030 because after a string all the + will be treated as string concatenation operator (not binary +).
34) In which location cookies are stored on the hard disk?
The storage of cookies on the hard disk depends on the OS and the browser.
The Netscape Navigator on Windows uses a cookies.txt file that contains all the cookies. The path is c:\Program Files\Netscape\Users\username\cookies.txt
For example: If you use it in a form element, it prevents it from submitting. If used in an anchor element, it prevents it from navigating. If used in a contextmenu, it prevents it from showing or displaying.
On the other hand, the event.stopPropagation() method is used to stop the propagation of an event or stop the event from occurring in the bubbling or capturing phase.
37) How can you check if the event.preventDefault() method was used in an element?
When we use the event.defaultPrevent() method in the event object returns a Boolean indicating that the event.preventDefault() was called in a particular element.
38) What is the difference between undefined value and null value?
Undefined value: A value that is not defined and has no keyword is known as undefined value. For example:
Null value: A value that is explicitly specified by the keyword "null" is known as a null value. For example:
40) What is this [[]]?
This is a three-dimensional array.
42) What is negative infinity?
43) What is the difference between View state and Session state?
"View state" is specific to a page in a session whereas "Session state" is specific to a user or browser that can be accessed across all pages in the web application.
The navigator.appVersion string can be used to detect the operating system on the client machine.
Yes, because it doesn't require web server's support for execution.
The this keyword is a reference variable that refers to the current object. For example:
To perform debugging, we can use any of the following approaches:
Those values which become false while converting to Boolean are called falsy values.
We can check if a value is falsy by using the Boolean function or the Double NOT operator (!!).
1) Which of the following statement is true?
Answer: B is the correct option.
3) Which of the following syntax is valid for creating a RegExp object?
Answer: C: Both the statements are correct and can be used for creating a RegExp object.
4) Which of the following statement specifies the meaning of Augmenting classes?
Answer: A: "Objects inherit prototype properties even in a dynamic state" is the correct answer.
5) If para1 is the DOM object for a paragraph, which of the following would be the correct syntax to change the text within the paragraph?
Answer: C: "para1.value="New Text";" is the correct syntax to change the text within the paragraph.
6) Which of the following is used to define the behavior of the instances present of a class inside a method?
Answer: B: "Classes" is the correct answer. The class's behavior is defined by the class and is shared by all instances.
7) Which of the following statement is true in the case of the property of the JSON() method?
8) Which of the following statement is true if class B can extend another class A?
Answer: A: "A is the superclass and B is the subclass" is the correct answer. A class is called a superclass if it can define a subclass. Subclasses are also called extensions of a superclass.
9) Which of the following is the correct syntax of the eval() function?
Answer: B: 11, 12 is the correct answer. The Object.assign() method is used to copy the properties and values of one object to another.
Other Interview QuestionsCore Java Interview Questions
Servlet Interview Questions
JSP Interview Questions
SQL Interview Questions
PL/SQL Interview Questions
Android Interview Questions