JavaScript
Q1. Type Conversion in JS?
Ans: Type conversion is used to convert the data type of the data. There are two methods available in javascript which are the following:
parseInt(): It is used to convert data into integer format.
parseFloat(): It is used to convert data into decimal format.
It is mostly used when we work on calculation-related work like EMI calculator, when we get data from the user through input we get the data in string format then we calculate input data which gives the wrong output. So here we need type conversion.
Q2. ES6 most used Features?
Ans: ES6's most used features are the following:
- Backticks(``)
- Spread operator (…)
- Let, const
- Map
- Class
- Objects
- Array destructuring
- Inheritance
- Bind, apply, call
Q3. this keyword in JS?
Ans: this keyword is used when you want to point out a particular element in a list of elements.
Example: there are 5 to 6 images and you want to pass image source to function on click of the image then we use this keyword to point out the particular clicked image.
this keyword is also used in class to point out the class variable.
Q4. Event Bubbling vs Event Capturing?
Ans: There are two problems when we use events on nested elements are following:
Event Bubbling: In the event bubbling the innermost event executes first then its parent, ancestors. It goes from bottom to top.
For example: when we use events on a nested element then it executes first where we occurred event then its parents. So it is problem to resolve this problem we use event.stopPropagation().
Event Capturing: In the event capturing the outermost event executes first then its child. It goes from top to bottom.
Example: In the event capturing when we use the event on a nested element then it executes first where we occurred event then its children. So it is problem to resolve this we first convert event capturing into bubbling then we use event.stop propagation().
To learn this topic in detail you can check this blog: event bubbling and event capturing.
Q5. What is DOM?
Ans: DOM is called Document Object Model, when our browser loads our web page then it creates a structure of the code, that structure is called DOM.
DOM is used to change HTML content, change CSS, add HTML content, and remove elements by using javascript selectors and DOM methods.
Q6. Mostly used JS Events?
Ans: There are the following mostly used events in javascript:
- click: click event is used when the user clicks a mouse.
- keyup: when the user releases a keyboard key.
- change: when the user changes the value of select.radio, checkbox.
- mouseover: when the user mouse over.
- scroll: when the user scrolls the scrollbar.
- Load: When the browser loads the content.
Q7. Difference Between === and == operator in JS?
Ans: === operator match content and its data type also.
== operator matches content only it does not match data type.
Q8. What is NAN in JS?
Ans: NAN is short for not a number, javascript shows an error when using numbers illegally or in the wrong way.
In a javascript there is a function isNaN(), it is used to check a number is nan or not.
Q9. Timing Events in JS?
Ans: There are 2 timing methods in JavaScript which are the following:
setTimeout(): It executes code after a specified duration. It executes code one time.
setInterval(): It executes code after a specified duration. It repeats code after a specified duration continuously.
To learn this topic in detail you can check this blog: Difference between setTimeout() and setInterval().
Q10. preventDefault() in JS?
Ans: preventDefault() in javascript is used to stop the default behavior of the element.
For example, the <a> tag is used to link pages but if we use prevent default onclick of a tag then it will not redirect to the page, because preventDefault stops the behavior of the <a> tag.
It is also used in submit button to prevent the form submission on click of submitting.
Q11. Difference between let and var in JS?
Ans: var: is used to hold data, it works like a container to hold the data, but there is a lack of var keyword it can be used first and we can declare at last.
let: we can say that it is an improved version of the var keyword. It was introduced in es6, let keyword cannot be used without declaration.
const: As its name suggests, it is used to declare a value that will not be overridden, like the value of pie: 3.14.
Q12. What do you mean by NULL in JS?
Ans: Null is a primitive data type, it is used to declare a variable with no value. It is like a blank value “ ” of the variable.
Example: var num=null;
Q13. What is an undefined value in JS?
Ans: undefined value is an error, javascript throws an error when a variable has been declared and no value has been given to it.
Example:
var a=5;
var b;
var c=a+b;
Q14. What is the use void(0)?
Q15. Web Storage API of HTML?
Q16. Object in JS?
Q18. Array methods in JS?
Q19. Use of break and continue statement?
Q20. String methods in JS?
I hope these questions will help the fresher developers to crack the interview, soon we will update interview questions with answers on our website.
"