10 question javascript
10 question javascript
1. What is JavaScript?
● JavaScript is a versatile scripting language primarily used for creating interactive web
pages. It runs on the client-side, allowing for dynamic content, user interactions, and web
application development.
2. What are the different data types in JavaScript?
● JavaScript supports various data types:
○ Primitive Data Types:
■ Number
■ String
■ Boolean
■ Undefined
■ Null
■ Symbol (ES6)
○ Complex Data Type:
■ Object
3. Explain the concept of variables and how to declare them in JavaScript.
● Variables are containers used to store data values. They are declared using the var, let, or
const keywords.
○ var: Function-scoped or globally scoped.
○ let: Block-scoped.
○ const: Block-scoped and cannot be reassigned.
4. What are operators in JavaScript?
● Operators are symbols used to perform operations on variables and values. JavaScript
supports various operators:
○ Arithmetic operators (+, -, *, /, %, ++, --)
○ Assignment operators (=, +=, -=, *=, /=, %=)
○ Comparison operators (==, ===, !=, !==, >, <, >=, <=)
○ Logical operators (&&, ||, !)
5. What is a function in JavaScript?
● A function is a block of code designed to perform a specific task. It can be reused multiple
times throughout the code. Functions are defined using the function keyword.
6. Explain the concept of DOM manipulation in JavaScript.
● DOM (Document Object Model) represents the structure of an HTML document as a
tree-like structure. JavaScript can manipulate the DOM to dynamically change the
content, style, and structure of the page.
7. What is an event in JavaScript?
● An event is an action or occurrence that happens in a web page, such as clicking a
button, hovering over an element, or submitting a form. JavaScript can respond to these
events and execute specific code.
8. What is the difference between == and === operators?
● == (loose equality): Compares values after type coercion.
● === (strict equality): Compares both value and type.
9. What is the purpose of the this keyword in JavaScript?
● The this keyword refers to the object that the current function is a method of. Its value
depends on how the function is called.
10. What is asynchronous JavaScript?
● Asynchronous JavaScript allows code to execute without blocking the main thread. It's
often used for tasks like fetching data from a server or handling timeouts. Techniques like
callbacks, promises, and async/await are used to handle asynchronous operations.
● https://github.com/Hakolostar/JavaScript
● https://github.com/sajalsa86/js-basic