Skip to content

Commit b5820f1

Browse files
authored
Added questions 68-70
1 parent 0147fd9 commit b5820f1

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

README.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
| 65 | [Difference between an Alert Box and a Confirmation Box](#65-difference-between-an-alert-box-and-a-confirmation-box) |
7373
| 66 | [How can we handle exceptions with javascript](#66-how-can-we-handle-exceptions-with-javascript) |
7474
| 67 | [What are the advantages of using External JavaScript](#67-what-are-the-advantages-of-using-external-javascript) |
75+
| 68 | [What is an anonymous function](#68-what-is-an-anonymous-function) |
76+
| 69 | [What is a first order function](#69-what-is-a-first-order-function) |
77+
| 70 | [Different ways to access object properties in javascript](#70-different-ways-to-access-object-properties-in-javascript) |
7578

7679
### 1. What is JavaScript
7780
* JavaScript is a scripting language used to create dynamic and interactive websites. It is supported by all major web browsers.
@@ -98,7 +101,7 @@ var person = {
98101
occupation: 'Software Engineer'
99102
}
100103
```
101-
##### b) Object.create method: TCreates a new object, by using an existing object as the prototype of the newly created object.
104+
##### b) Object.create method: It Creates a new object, by using an existing object as the prototype of the newly created object.
102105

103106
```javascript
104107
const person = {
@@ -110,7 +113,6 @@ const person = {
110113
var info = Object.create(person);
111114
console.log(info.name); // output - Surbhi
112115
```
113-
Here "person" is an existing object which is passed as a prototype to the newly created object "info"
114116

115117
##### c) Object constructor: Constructor function allows to create objects with the help of new keyword
116118

@@ -128,7 +130,6 @@ class Person {
128130
}
129131

130132
let person = new Person('Surbhi');
131-
132133
console.log(person.name); //output - Surbhi
133134
```
134135

@@ -161,7 +162,7 @@ const functionName = (something) => {
161162
```
162163
###### Features of arrow functions
163164
1. They use a concise syntax which makes them shorter and easier to read as compared to traditional function expressions
164-
2. They do not bind their own this value, but instead inherit the this value from the enclosing lexical scope (i.e., the scope in which it is defined)
165+
2. They do not bind their own this value, but instead inherit the this value from the enclosing lexical scope
165166
3. They do not have "prototype" property and hence cannot be used as a constructor
166167
4. If the arrow function body consists of a single expression, that expression will be implicitly returned, without the need for a return statement.
167168
5. If an arrow function has only one parameter, the parentheses around the parameter list can be omitted.
@@ -180,7 +181,6 @@ const arr = [1,2,3];
180181
const [num1, num2, num3] = arr;
181182
console.log(num1); // output =====> 1
182183
console.log(num2); // output =====> 2
183-
console.log(num3); // output =====> 3
184184
```
185185
**[:top: Scroll to Top](#javascript-interview-questions)**
186186

@@ -261,14 +261,12 @@ Hoisting is a default behavior in JavaScript where variable and function declara
261261
console.log(a); // output =====> undefined
262262
var a = 10;
263263
```
264-
The output of above code will be undefined because the declaration of "a" is hoisted to the top of the scope, but the initialization happens later in the code.
265264

266265
```javascript
267266
a=10;
268267
console.log(a); // output =====> 10
269268
var a;
270269
```
271-
The output of above code will be 10 because the variable "a" is hoisted to the top of the scope and its value is assigned before console.log
272270

273271
**Function hoisting**
274272
```javascript
@@ -277,7 +275,7 @@ function demo() {
277275
console.log('demo console');
278276
}
279277
```
280-
The output of above code will be "demo console" because the function declaration is hoisted to the top of the scope, allowing it to be called before it is declared in the code.
278+
281279
```diff
282280
**Note**
283281
+ Only function declarations are hoisted, not the function expressions.
@@ -693,10 +691,8 @@ let var1 = "Surbhi";
693691
let var2 = 10;
694692
console.log(typeof var1); // output ========> "string"
695693
console.log(typeof var2); // output ========> "number"
696-
console.log(typeof "hello"); // output ========> "string"
697-
console.log(typeof 2); // output ========> "number"
698-
console.log(typeof true); // output ========> "boolean"
699694
```
695+
700696
**[:top: Scroll to Top](#javascript-interview-questions)**
701697
702698
### 41. Is JavaScript case-sensitive
@@ -1021,6 +1017,44 @@ try {
10211017
10221018
**[:top: Scroll to Top](#javascript-interview-questions)**
10231019
1020+
### 68. What is an anonymous function
1021+
An anonymous function is a function that does not have a name. It is common to assign anonymous functions to a variable or use them as callback functions.
1022+
```js
1023+
const sayHi = function() {
1024+
console.log("Hi there!!");
1025+
};
1026+
sayHi();
1027+
```
1028+
**[:top: Scroll to Top](#javascript-interview-questions)**
1029+
1030+
### 69. What is a first order function
1031+
A first order function is a function that does not take any other functions as arguments and does not return any function as its result.
1032+
```js
1033+
function sayHello() {
1034+
console.log("A first order function")
1035+
}
1036+
sayHello();
1037+
```
1038+
1039+
**[:top: Scroll to Top](#javascript-interview-questions)**
1040+
1041+
### 70. Different ways to access object properties in javascript
1042+
**Dot notation** - It uses dot (.) to access the object properties.
1043+
```js
1044+
object.propertyName
1045+
```
1046+
**Bracket notation** - It uses bracket "[ ]" to access the object properties.
1047+
```js
1048+
object[propertyName]
1049+
```
1050+
**Object destructuring** - It creates variables that correspond to the object properties.
1051+
```js
1052+
const obj1 = {name : "surbhi", designation : "SE"}
1053+
const {name , designation} = obj1;
1054+
console.log(name, designation) // output ========> "Surbhi","SE"
1055+
```
1056+
1057+
**[:top: Scroll to Top](#javascript-interview-questions)**
10241058
10251059
## Output Based Questions
10261060

0 commit comments

Comments
 (0)