@@ -27,17 +27,70 @@ Top JavaScript interview questions
27
27
| 19 | [ Difference between Call, apply, bind] ( #19-difference-between-call-apply-bind ) |
28
28
29
29
### 1. What is JavaScript
30
+ * JavaScript is the world's most popular programming language used for web development. It can be used to update HTML and CSS
31
+ * Nowadays, JavaScript is getting used in many other areas e.g. server-side development, mobile app development etc.
30
32
31
33
### 2. What are the different data types in JavaScript
34
+ | Primitive | Non-primitive |
35
+ | ------------- | ------------- |
36
+ | Boolean, NULL, undefined, BigInt, String, Number, Symbol | Object |
32
37
33
38
### 3. What are the different ways to create an Object in JavaScript
34
39
40
+ ##### a) Object Literals: A comma-separated set of name and value pairs that is wrapped inside curly braces.
41
+
42
+ ```
43
+ var person = {
44
+ name: 'Surbhi',
45
+ age: 25,
46
+ occupation: 'Software Engineer'
47
+ }
48
+ ```
49
+ ##### b) Object.create method: TCreates a new object, by using an existing object as the prototype of the newly created object.
50
+
51
+ ```
52
+ const person = {
53
+ name: 'Surbhi',
54
+ age: 25,
55
+ occupation: 'Software Engineer'
56
+ }
57
+
58
+ var info = Object.create(person);
59
+ console.log(info.name); // output - Surbhi
60
+
61
+ Here "person" is an existing object which is passed as a prototype to the newly created object "info"
62
+ ```
63
+
64
+ ##### c) Object constructor: Constructor function allows to create objects with the help of new keyword
65
+
66
+ ```
67
+ const person = new Person();
68
+ ```
69
+
70
+ ##### d) using ES6: We can create object using ES6 class feature
71
+
72
+ ```
73
+ class Person {
74
+ constructor(name) {
75
+ this.name = name;
76
+ }
77
+ }
78
+
79
+ let person = new Person('Surbhi');
80
+
81
+ console.log(person.name); //output - Surbhi
82
+ ```
83
+
35
84
### 4. Difference between "==" and "===" operators
85
+ * == : While comparing two operands, checks for only value
86
+ * === : While comparing two operands, checks for value as well as data type
36
87
37
88
### 5. Is javascript single-threaded or multi-threaded
89
+ * JavaScript is Single-threaded
38
90
39
91
### 6. What are arrow functions and its features
40
92
93
+
41
94
### 7. Explain passed by value and passed by reference
42
95
43
96
### 8. What do you mean by Synthetic events
@@ -51,6 +104,13 @@ Top JavaScript interview questions
51
104
### 12. What are promises
52
105
53
106
### 13. Can we combine two arrays using any es6 operators
107
+ * Yes, using Spread Operators
108
+ ```
109
+ const arr1 = [1,2,3,4];
110
+ const arr2 = [5,6];
111
+ const arr3 = [...arr1, ...arr2]
112
+ console.log(arr3) //output - [1,2,3,4,5,6]
113
+ ```
54
114
55
115
### 14. Difference between let, var, const
56
116
0 commit comments