Javascript top 10 basic interview questions

Q1. What is javascript?

Ans. JavaScript is a scripting language that allows us to include new features on web pages. It can update/change both HTML and CSS. It is also use to calculate, manipulate and validate data on client side.

Q2. From where I can get or download JavaScript?

Ans. JavaScript is free to available for everyone. We don’t have to download it from anywhere. It is already available in our browser on our system.

Q3. Can we assign values in double or single quotes in JavaScript?

Ans. Yes, We can assign values in both single & double quotes in javaScript.

Q4. Is javascript case sensitive?

Ans. Yes, JavaScript is case-sensitive. If we create two variables userName and username, then these two variables are considered differently whereas their spelling is the same.

Q5. How to add comments in JavaScript?

Ans. The single-line comment starts with //. Any text after // will be ignored by JavaScript. The Multi-line comments start with /* and end with /. Any text between / and */ will be ignored by JavaScript.

For Example:-

let website = 'quizforyou-in-216390.hostingersite.com';      // Declare website variable & value of it. This is single line comment.

/*
 Declare website variable & value of it.
 This is multi-line comment.
*/

Q6. How many ways we can declare variables in JavaScript?

Ans. We can declare variables in 4 Ways:
(a) By using the var keyword
(b) By using let keyword
(c) By using the const keyword
(d) By without any keyword

Q7. What are Variables in JavaScript?

Ans. Variables are just like a containers which are used for storing data in that.

Q8. What is the difference between var, let & const keywords?

Ans. The difference between var,let & const is given below:-

VarLetConst
This oldest keyword, was added in 1995This is newly added keyword added in 2015 in JavaScript. This is also a newly added keyword added in 2015 in JavaScript.
It have global scoped and function scoped means the variables defined outside the function can be accessed globally anywhere, and variables defined inside a particular function can be accessed within the function only.Its variable have only block scoped, means it can’t be access outside the block ({block})Its variable also have block scope.
We can easily re-declare the variable defined using var keyword and its value can be update as well.We can’t re-declare the variable defined using let keyword but its value can be update it.It is also can’t be re-declare same variable using const keyword and can’t update its variable value.

Q9. How many way we can display output in JavaScript?

Ans. In javaScript we can display output in 4 ways:-

(a) By using innerHTML
(b) By using document.write()
(c) By using window.alert()
(d) By using console.log()

Q10. Which HTML element tag is use to write JavaScript code?

Ans. The tag is used to write the javaScript code.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top