Latest

6/recent/ticker-posts

Top 20 JavaScript Interview Questions and Answers for Fresher

Top 20 JavaScript Interview Questions and Answers for Fresher

Top 20 JavaScript Interview Questions and Answers for Fresher



1) Define JavaScript in Web development?

Ans. JavaScript is an object-based client and server-side case-sensitive language.JavaScript is also known as vanilla JavaScript.The main use of JavaScript is to create interacting web pages modern Websites and Web applications.

2) What are the main uses of JavaScript language?

Ans. The main uses of javaScript are-

a) JavaScript provide client-side validation for incorrect or invalid data.
b) JavScript helps we can create Date and Time.
C) Using javaScript in the Website we can create dynamic drop-down menus.
d) To create an alert dialog box, prompt dialog box, confirm box and display pop-up window we used javaScript.

3) Write the difference between Java and JavaScript language?

Ans. The main difference between java and JavaScript language is-

No.

Java         

JavaScript

1

Java is an object-oriented programming language.

 JavaScript is an object-based Scripting language.

2

Java is a server-side language.

JavaScript is a server and client-side language.

3

To run java code require JDK

For the run, javaScript code requires a text-editor like Notepad, etc

4

Using java helps we can create any type of application like a Mobile application. Desktop application, Web-based applications, Enterprise Applications. etc.

Using JavaScript we can create an interactive web application, website, etc.  


4) Write the name of JavaScript Data Types?

Ans. JavaScript Data Types mainly divided into 3 types:

1) Primitive data type or Primary  data type:
            
  The primitive data type in JavaScript mainly 3 types-
  a) String 
  b) Number
  c) Boolean.


2) Reference data type  or Composite data type:
 
           
 The Composite data type mainly 3 types-
a) Object
b) Array
c) Function.


3) Special data type: 
       
    Special data types mainly 2 types-
a) Undefined
b) Null.

5) Define Event in javaScript?

Ans. If we change the state of the object is called  Event. The event is also used to call the function. for example, if we submit the form, submit is called an event.

6) Write the name of Mouse HTML Event with JavaScript Event Handler?

Ans. The name of Mouse HTML Event with JavaScript Event Handler is-


          No.

Event

Event Handler

1

click

onclick

2

mouseup

onmouseup

3

mousedown

onmousedown 

4

mouseout

onmouseout

5

mouseover

onmouseover

6

mousemove

onmousemove

 

7) Write the name of the Form HTML event also write the javaScript Event Handler?

Ans. The Form HTML Event and JavaScript Event Handler are-

 

No.

Event

Event Handler

1

focus

onfocus

2

blur

onblur

3

change

onchange

4

submit

onsubmit. 

 

8) Write the name of the Keyboard event and also write the event handler?

Ans. There are 2 events Keydown and Keyup which is handled by onkeydown and onkeyup.


9) Write the difference between == and === operator?

Ans. The main difference between == and === operator is- == operator only compare the value and ==== operatore compare both type and values.


10) Write the name of JavaScript Popup Box or Dialog boxes?

Ans. JavaScript provides the 3 types of Popup Box they are-

1) Alert box 
2) Confirm box
3) Prompt box.


11) Define Alert Box in javaScript?

Ans. The Alert box is used to display the warning message to the users. In the alert box, the user will press the ok button and continue the work.


12) Define the Confirm box?

Ans. Confirm box display the message and take permission from the user it allows 2 buttons, ok, and cancel. If we press ok it returns true, if we press cancel return false.


13) Define Prompt Box?

Ans. If we want to take user input and display the message use Prompt Box. The input which is user entered and click ok so it's displayed in text-box. If the user clicks cancel so it returns null.


14) Explain Closure in javaScript?

Ans. Closure provides access from an inner function to the outer function variable scope. In other words, A Closure is a function having access to the parent scope, even after the parent function has closed.

 In there are 3 scopes in Closure-
a) Local Scope 
b) Outer Function Scope
c) Global Scope.


15) Explain DOM in JavaScript?

Ans.DOM stands for Document Object Model.DOM represents the HTML and XML document.It is a platform and language-independent model that defines the logical structure of the document. All the Html element in DOM define as an object. The main uses of the Document Object Model are we can include the dynamic content to our web page.

16) How we can Target DOM Object?

Ans. There are 3 ways which help we can target the DOM Object-
a) By Id=document.getElementById('idname').
b) By Class Name=document.getElementsByClassName('classname').
c) By Tag Name=document.getElementsByTagName('tagname').

17) Define BOM in JavaScript?

Ans. BOM stands for Browser Object Model. The main use of the Browser object Model is used to communicate or interact with the browser. The default object of the browser is a Window.


18) Explain Event Capturing?

Ans. In javaScript an Event that begins from the top element to the target element called Event Capturing. Present-time Modern browser does not support Event Capturing.


19) Explain Event Bubbling in javaScript?

Ans. Event Bubbling is an order which is starts from the target element to its parent element. By default, Event Bubbling present in all modern browsers. In Event Bubbling, one Element is nested inside a second element and both elements have registered a listener for the same event.


20) Write the famous JavaScript framework name?

Ans. The Famous JavaScript framework is-
a) Angular Js
b) React Js
c) Vue Js.


 The main aim of this blog to give information on the Top 20 JavaScript Interview Questions and Answers for Fresher. If you like the article share the feedback, and also, write comments if you find anything incorrect


Post a Comment

0 Comments