Site icon Job Portal

JavaScript Interview Questions for front end Developer

Javascript Interview Questions for front end Developer

Javascript Interview Questions for front end Developer

Introduction:

JavaScript is a programming language that is one of the core technologies of the World Wide Web (W3), alongside HTML and CSS. Over 97% of websites use JavaScript on the client-side for web page behavior.

Question 1:What is the correct syntax for referring to an external script called “script.js”?

Answer:<script src=”script.js”>

Question 2:How do you wirte “welcome to this page !” in an alert?

Answer: alert(” welcome to this page ! “);

Question 3: What is the best space to insert javascript code?

Answer: In the bottom of body tag.

Question 4:What is the correct JavaScript syntax to change the content of the HTML element below?

Answer:document.getElementById(“para”).innerHTML = “Welcome to this class!”;

Question 5:How do you create a function in JavaScript?

Answer:In script file create function add().

Question 6:How can you add a comment in a JavaScript?

Answer: // this use or comment

Question 7:How to insert a comment that has more than one line?

Answer:/*This comment has more than one line…*/

Question 8:What is the correct way to write a JavaScript array?

Answer: var car=[“SUV”,Mehran”,”Alto”]

Question 9: What is different between var and let?

Answer: var is publically. let is used inside the block out of block doesn’t access.

Question 10:Which event occurs when the user clicks on an HTML element?

Answer:onclick

Question 11:How do you declare a JavaScript variable?

Answer: var number1,number2

Question 12:Is JavaScript case-sensitive?

Answer: yes JavaScript is case-sensitive.

Question 13:What is the function used for all calculation of mathematic number?

Answer: eval function is used.

Question 14: What is NaN property in JavaScript?

Answer: NaN property represents the “Not-a-Number” value.

Question 15: How to can change variable types?

Answer: we can check types to used function typeof()

Question 16: what is JavaScript Const?

Answer: Variables defined  const cannot be Reassigned and const have Block Scope.

Question 17: whats is differnet querySelector and querySelectorAll?

Answer:querySelector: returns the first element within the document that matches the specified group of selectors.

querySelectorAll: returns an array of objects with the elements that match the specified group of selectors.
Syntax.

Question 18: what is JavaScript HTML DOM Events?

Answer: JavaScript can be executed when an event occurs, like when a user clicks on an HTML element. An event is also like a function performed.

Question 19: what is JavaScript HTML DOM EventListener?

Answer: Add an event listener that fires when a user clicks a button or mouseover.

document.getElementById(“btnID”).addEventListener(“click”, showData);

Question 20: How to Add an Event Handler to an Element?

Answer: when the user clicks on an element on this function Alert “Welcome to this page!”

<script>

document.getElementById(“btnId”).addEventListener(“click”, function(){

alert(“welcome to this page!”);

});

</script>

You may also like:

Exit mobile version