Here are 20 sample exam/interview questions and answers for JavaScript for bachelor studies:
- What is the difference between let and var in JavaScript?
- What is the difference between == and === in JavaScript?
==
compares values for equality and===
compares values and data types for equality.
- How do you define a function in JavaScript?
- Functions can
be defined using thefunction
keyword or using arrow notation.
- What is an object in JavaScript?
- An object in JavaScript is a collection of key-value pairs.
- What is the difference between null and undefined in JavaScript?
null
is a value that represents no value, whileundefined
means that a variable has been declared but has not been assigned a value.
- What is the difference between == and === in JavaScript?
==
compares values for equality and===
compares values and data types for equality.
- What is the difference between == and === in JavaScript?
==
compares values for equality and===
compares values and data types for equality.
- How do you create an array in JavaScript?
[]
notation or the Array()
constructor.- How do you loop through an array in JavaScript?
for
loop, forEach()
method, map()
method or for...of
loop- How do you create an object in JavaScript?
- How do you access properties of an object in JavaScript?
- What is the difference between a while loop and a do-while loop in JavaScript?
- A while loop checks the condition before executing the loop, while a do-while loop executes the loop first and then checks the condition.
- What is the purpose of the break statement in JavaScript?
- The break statement is used to exit a loop or a switch statement.
- What is the difference between the continue and break statements in JavaScript?
- The continue statement is used to skip the current iteration of a loop, while the break statement is used to exit a loop or a switch statement.
- What is the difference between a local variable and a global variable in JavaScript?
- A local variable is defined within a function and is only accessible within that function, while a global variable is defined outside of any function and is accessible throughout the entire program.
- What is a closure in JavaScript?
- A closure is a function that has access to the variables in its parent scope, even after the parent function has completed execution.
- What is a promise in JavaScript?
- A promise is an object that represents the eventual completion of an asynchronous operation.
- What is an event in JavaScript?
- An event in JavaScript is an action or occurrence that can be detected by the program.
- What is the difference between callbacks and promises in JavaScript?
- Callbacks are a way to handle async operations by passing a function as an argument, while Promises provide a more powerful and flexible way to handle async operations.
- What is the difference between == and === in javascript
==
compares values for equality and===
compares values and data types for equality.
Please keep in mind that these questions and answers are just a sample and are not exhaustive. Additionally, I suggest double-checking the answers and also checking the latest JavaScript standards and best practices as the field is constantly evolving.
No comments:
Post a Comment