JavaScript Basic Question and Answers

MD.Rashaduzamman Rian
3 min readMay 8, 2021

01. Difference between == & ===?

Ans: Double equal (==) will only check value is equal or not and triple equal will check value and data type

Example:

let first= 2;

let second=’2’;

if(first==second){

console.log(‘Condition true’)

else{

console.log(‘condition false’)

result: condition true, if we put triple equal instead of double equal, the result will be false

02. What is closer in JavaScript?

Ans: If we return a function from a function. It creates a close environment. It’s called closer .

Example:

function stopwatch(){

const count=0;

return function(){

count++;

};

};

03. What is setTimeout in JavaScript?

Ans: setTimeout work in an async way. It will execute depends on time-out parameter. It will execute once.

04. What are truthy Values in JavaScript?

Ans: ‘0’, ‘ ’, [],{}

05. What is false in JavaScript?

Ans: false,0,””,undefined, null, NaN

06. What is the difference between let and const?

Ans: you cannot change the value for const, can be changed by array & object. but you can change the value for let by declaring again and again.

07. What is DOM?

Ans: DOM is Document Object Model. Its works like a reverse tree.

08. What is an API?

Ans: Application Programming Interface When you use an application on your mobile phone, the application connects to the Internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions, and sends it back to your phone. The application then interprets that data and presents you with the information you wanted in a readable way. This is what an API is — all of this happens via API.

09. How GET requests Works With API?

When you’re creating tests for an API, the GET method will likely be the most frequent type of request made by consumers of the service, so it’s important to check every known endpoint with a GET request.

At a basic level, these things should be validated:

  • Check that a valid GET request returns a 200-status code.
  • Ensure that a GET request to a specific resource returns the correct data. For example, GET /users return a list of users.

10. How POST requests Work with API?

The second most common HTTP method you’ll encounter in your API tests is POST. POST requests are used to send data to the API server and create or update a resource. Since POST requests modify data, it’s important to have API tests for all of your POST methods.

Here are some tips for testing POST requests:

  • Create a resource with a POST request and ensure a 200 status code is returned.
  • Next, make a GET request for that resource, and ensure the data was saved correctly.
  • Add tests that ensure POST requests fail with incorrect or ill-formatted data.

--

--