interview Flashcards

1
Q

What is DOM in JavaScript?

A

JavaScript can access all the elements in a web page using the Document Object Model (DOM). The web browser creates a DOM of the webpage when the page is loaded.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to use DOM and Events?

A

Using DOM, JavaScript can perform multiple tasks. It can create new elements and attributes, change the existing elements and attributes and even remove existing elements and attributes. JavaScript can also react to existing events and create new events in the page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Loop Though the Properties of an Object?

A

The for/in a loop is usually used to loop through the properties of an object. You can give any name for the variable, but the object’s name should be the same as an already existing object you need to loop through.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to use Loops in Javascript?

A

for loop
Statement1 is executed first, even before executing the looping code. So, this statement is normally used to assign values to variables used inside the loop.
The statement2 is the condition to execute the loop.
The statement3 is executed every time after the looping code is executed.
for/in a loop (explained later)
The for/in a loop is usually used to loop through the properties of an object. You can give any name for the variable, but the object’s name should be the same as an already existing object you need to loop through.

while loop
The “while loop” is executed as long as the specified condition is true. Inside the while loop, you should include the statement that will end the loop at some point in time. Otherwise, your loop will never end, and your browser may crash.
do…while loop
The do…while loop is very similar to the while loop. The only difference is that in do…while loop, the block of code gets executed once even before checking the condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to use Loop in JavaScript?

A

Loops are useful when you repeatedly execute the same lines of code a specific number of times or as long as a specific condition is true. Suppose you want to type a ‘Hello’ message 100 times on your webpage. Of course, you will have to copy and paste the same line 100 times. Instead, if you use loops, you can complete this task in just 3 or 4 lines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are JavaScript and ECMA Script related?

A

ECMA Script is like rules and guidelines, while Javascript is a scripting language used for web development.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why you should not use innerHTML in JavaScript?

A

innerHTML content is refreshed every time and thus is slower.
//
Textcontent is faster

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the unshift() method?

A

This method is functional at the starting of the array, unlike the push(). It adds the desired number of elements to the top of an array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the decodeURI() and encodeURI()?

A

EncodeURl() is used to convert URL into their hex coding. And DecodeURI() is used to convert the encoded URL back to normal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write about the errors shown in JavaScript?

A

Load-time errors - errors shown at the time of the page loading
Runtime errors - error that comes up while the program is running.
Logic errors - infinite loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are event handlers utilized in JavaScript?

A

Events are the actions that result from activities, such as clicking a link or filling a form by the user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What boolean operators can be used in JavaScript?

A

The ‘And’ Operator (&&), ‘Or’ Operator (||), and the ‘Not’ Operator (!) can be used in JavaScript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is event bubbling?

A

JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of the parent will also work as if it were clicked too.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between .call() and .apply()?

A

.call() is used when the number of the function’s arguments are known to the programmer,
person.fullName.call(person1, “Oslo”, “Norway”);

apply() method accepts arguments in an array:
person.fullName.apply(person1, [“Oslo”, “Norway”]);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the important properties of an anonymous function in JavaScript?

A

A function that is declared without any named identifier is known as an anonymous function. In general, an anonymous function is inaccessible after its declaration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How closures work in JavaScript?

A

The closure is a locally declared variable related to a function that stays in memory when it has returned.

17
Q

What is the use of the blur function?

A

Blur function is used to remove the focus from the specified object.

18
Q

What is break and continue statements?

A

Break statement exits from the current loop.

Continue statement continues with next statement of the loop.

19
Q

What are JavaScript Cookies?

A

Cookies are the small test files stored in a computer, and they get created when the user visits the websites to store information that they need.

20
Q

What are escape characters?

A

Escape characters (Backslash) is used when working with special characters like single quotes, double quotes, apostrophes, and ampersands. Place backslash before the characters to make it display.

21
Q

What is the data type of variables in JavaScript?

A

All variables in JavaScript are object data types.

22
Q

What is called Variable typing in Javascript?

A

Variable typing is used to assign a number to a variable. The same variable can be assigned to a string.

23
Q

What is the working of timers in JavaScript?

A

Timers are used to execute a piece of code at a set time or repeat the code in a given interval. This is done by using the functions setTimeout, setInterval, and clearInterval.

24
Q

What is ‘this’ keyword in JavaScript?

A

‘This’ keyword refers to the object from where it was called.

25
Q

What are JavaScript Data Types?

A
Number
String
Boolean
Object
Undefined
26
Q

What is JavaScript?

A

JavaScript is a client-side and server-side scripting language inserted into HTML pages and is understood by web browsers

27
Q

What are the arrow functions in JavaScript?

A

Arrow functions are a short and concise way of writing functions in JavaScript.

28
Q

Difference between Libraries and frameworks

A

Libraries is predefined functions and classes to make work easier

Framework is like the foundation of platforms

29
Q

Closure

A

when you have a function defined inside of another function, that inner function has access to the variables and scope of the outer function even if the outer function finishes executing and those variables are no longer accessible outside of that function.

30
Q

recursion

A

function that calls itself somewhere inside of the function with an exit condition to prevent infinite loop

31
Q

what is express js?

A

web framework that let’s you structure a web application to handle multiple different http requests at a specific url

32
Q

Asynchronous and synchronous

A

Asynchronous does not block the execution of the program whereas synchronous functions block the execution of the program until it has finished processing.