Skip to content

Commit 329364c

Browse files
authored
Added Question-Answer 37-41
1 parent ca41975 commit 329364c

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ Top JavaScript interview questions
4141
| 33 | [What are the different ways to empty an array in javascript](#33-what-are-the-different-ways-to-empty-an-array-in-javascript) |
4242
| 34 | [What is NaN in javascript](#34-what-is-nan-in-javascript) |
4343
| 35 | [Javascript naming convention](#35-javascript-naming-convention) |
44-
| 36 | [Difference between call(), apply() and bind()](difference-between-call-apply-and-bind) |
45-
44+
| 36 | [Difference between call(), apply() and bind()](#36-difference-between-call-apply-and-bind) |
45+
| 37 | [What is the use of isNaN function](#37-what-is-the-use-of-isnan-function) |
46+
| 38 | [What is 'this' keyword in javascript](#38-what-is-this-keyword-in-javascript) |
47+
| 39 | [How do we add comments in javascript](#39-how-do-we-add-comments-in-javascript) |
48+
| 40 | [What is the use of typeof operator](#40-what-is-the-use-of-typeof-operator) |
49+
| 41 | [Is JavaScript case-sensitive](#41-is-javascript-case-sensitive) |
4650

4751
### 1. What is JavaScript
4852
* JavaScript is a scripting language used to create dynamic and interactive websites. It is supported by all major web browsers.
@@ -571,6 +575,56 @@ function printName(message) {
571575
let sayHello = printName.bind(person, "Hello");
572576
sayHello();
573577
```
578+
579+
### 37. What is the use of isNaN function
580+
isNaN() is a built-in JavaScript function. It takes a single argument and returns true if the argument is not a number, otherwise it returns false.
581+
```js
582+
let num1 = 5;
583+
let num2 = "hi";
584+
585+
console.log(isNaN(num1)); // output ========> false
586+
console.log(isNaN(num2)); // output ========> true
587+
```
588+
589+
### 38. What is 'this' keyword in javascript
590+
The value of 'this' is determined by the context in which it is used. In general, 'this' keyword refers to the object it belongs to.
591+
The 'this' keyword in JavaScript can have different values depending on where it is used -
592+
1. If it is used inside a method, then it refers to the object that it belongs to
593+
2. If it is used inside any function or alone (i.e outside any function or method), then it referes to the global object
594+
3. If it is used in the context of an event handler, such as a click event, then it refers to the element that triggered the event
595+
596+
### 39. How do we add comments in javascript
597+
**Single-line comments** - Add comments using 2 forward slashes //
598+
```js
599+
// this is a single line comment
600+
```
601+
**Multi-line comments** - Enclose the text between /* and */
602+
```js
603+
/*
604+
This is a
605+
multiline comment
606+
example
607+
*/
608+
```
609+
610+
### 40. What is the use of typeof operator
611+
The typeof operator returns a string that indicates the data type of the variable/value.
612+
```js
613+
let var1 = "Surbhi";
614+
let var2 = 10;
615+
console.log(typeof var1); // output ========> "string"
616+
console.log(typeof var2); // output ========> "number"
617+
console.log(typeof "hello"); // output ========> "string"
618+
console.log(typeof 2); // output ========> "number"
619+
console.log(typeof true); // output ========> "boolean"
620+
```
621+
622+
### 41. Is JavaScript case-sensitive
623+
Yes, JavaScript is a case-sensitive language. For e.g., the variables firstName and firstname are considered to be two different variables.
624+
```js
625+
let firstName = "Surbhi";
626+
console.log(firstname); // output ========> Uncaught ReferenceError: firstname is not defined
627+
```
574628
******************************In progress
575629
576630

0 commit comments

Comments
 (0)