Skip to content

Commit 1caac4b

Browse files
authored
Update README.md
1 parent e6fed13 commit 1caac4b

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,51 @@
6868

6969
let str = "Hello world, welcome to the JS Universe.";
7070
console.log(str.length); // 40
71-
```
71+
```
72+
73+
<a name="interview"></a><a name="1.6"></a>
74+
- [1.6](#length) **Interview Qus**: Tricky JavaScript Interview Questions and Answers
75+
76+
```javascript
77+
// remove duplicates form and array
78+
let arr = [1, 2, 2, 3, 4];
79+
80+
console.log([...new Set(arr)]);
81+
82+
// output test 1
83+
console.log(5 < 6 < 7); // true // 5 < 6 => true => true < 7 => true = 1 => 1 < 7 => true
84+
85+
console.log(7 > 6 > 5); // false // 7 > 6 => true => true > 5 => true = 1 => 1 > 5 = false
86+
87+
console.log(Math.max()); // -Infinity lowest min number in js
88+
console.log(Math.max(1, 2, 3, 4)); // 4
89+
90+
91+
// obj
92+
let profile = {
93+
name: 'Lakshman'
94+
};
95+
96+
// Object.freeze(profile); // freeze don't allow insert and update
97+
Object.seal(profile); // freeze don't allow insert, remove but allow update
98+
99+
profile.name = 'Gope';
100+
101+
console.log(profile);
102+
103+
// obj
104+
let user = {
105+
name: 'Gope'
106+
};
107+
108+
// age not allow any update but name does
109+
Object.defineProperty(user, 'age', {
110+
value: 4,
111+
writable: false
112+
})
113+
114+
user.name = 'Lakshman'
115+
user.age = 5;
116+
117+
console.log(user); // TypeError: Cannot assign to read only property 'age' of object '#<Object>'
118+
```

0 commit comments

Comments
 (0)