DevScrolls
14. All object have prototypes.
Explained ans will post today eod
Explained ans will post today eod
Answer: B
All objects have prototypes, except for the base object. The base object is the object created by the user, or an object that is created using the new keyword. The base object has access to some methods and properties, such as .toString. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
Object can created without prototype using Object.create(null, {}) with passing null args
All objects have prototypes, except for the base object. The base object is the object created by the user, or an object that is created using the new keyword. The base object has access to some methods and properties, such as .toString. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
Object can created without prototype using Object.create(null, {}) with passing null args
❤1
18. What's the output?
}
}
checkAge({ age: 18 });
A: You are an adult!
B: You are still an adult.
C: Hmm.. You don't have an age I guess
function checkAge(data) {
if (data === { age: 18 }) {
console.log('You are an adult!');
} else if (data == { age: 18 }) {
console.log('You are still an adult.');
} else {
console.log(Hmm.. You don't have an age I guess); }
}
checkAge({ age: 18 });
A: You are an adult!
B: You are still an adult.
C: Hmm.. You don't have an age I guess
👍1
DevScrolls
Output for the above?
Answer: C
When testing equality, primitives are compared by their value, while objects are compared by their reference. JavaScript checks if the objects have a reference to the same location in memory.
The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
This is why both { age: 18 } === { age: 18 } and { age: 18 } == { age: 18 } return false.
When testing equality, primitives are compared by their value, while objects are compared by their reference. JavaScript checks if the objects have a reference to the same location in memory.
The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
This is why both { age: 18 } === { age: 18 } and { age: 18 } == { age: 18 } return false.
Use css blend effect for cursor animation to make your website attractive 🤩 and know the difference between css position property vs transform property and when to use them to increase performance.
https://thedailyfrontend.com/cursor-animation-with-blend-effect/
https://thedailyfrontend.com/cursor-animation-with-blend-effect/
The Daily Frontend
Cursor animation with blend effect - The Daily Frontend
This articles helps you to make cursor animation with blend effect on a webpage using css mix-blend-mode property.
19. What's the output?
function getAge(...args) { console.log(typeof args); } getAge(21);
function getAge(...args) { console.log(typeof args); } getAge(21);
Anonymous Poll
47%
A: "number"
27%
B: "array"
13%
C: "object"
13%
D: "NaN"
DevScrolls
19. What's the output?
function getAge(...args) { console.log(typeof args); } getAge(21);
function getAge(...args) { console.log(typeof args); } getAge(21);
Answer: C
The rest parameter (...args) lets us "collect" all remaining arguments into an array. An array is an object, so typeof args returns "object"
The rest parameter (...args) lets us "collect" all remaining arguments into an array. An array is an object, so typeof args returns "object"
20. What's the output?
function getAge() { 'use strict'; age = 21; console.log(age); } getAge();
function getAge() { 'use strict'; age = 21; console.log(age); } getAge();
Anonymous Poll
38%
A: 21
34%
B: undefined
22%
C: ReferenceError
6%
D: TypeError
DevScrolls
20. What's the output?
function getAge() { 'use strict'; age = 21; console.log(age); } getAge();
function getAge() { 'use strict'; age = 21; console.log(age); } getAge();
Answer: C
With "use strict", you can make sure that you don't accidentally declare global variables. We never declared the variable age, and since we use "use strict", it will throw a reference error. If we didn't use "use strict", it would have worked, since the property age would have gotten added to the global object.
With "use strict", you can make sure that you don't accidentally declare global variables. We never declared the variable age, and since we use "use strict", it will throw a reference error. If we didn't use "use strict", it would have worked, since the property age would have gotten added to the global object.
21. What's the value of sum?
const sum = eval('10*10+5');
const sum = eval('10*10+5');
Anonymous Poll
32%
A: 105
38%
B: "105"
26%
C: TypeError
29%
D: "10*10+5"
DevScrolls
21. What's the value of sum?
const sum = eval('10*10+5');
const sum = eval('10*10+5');
Answer: A
eval evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is 10 * 10 + 5. This returns the number 105.
eval evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is 10 * 10 + 5. This returns the number 105.
22. How long is cool_secret accessible?
sessionStorage.setItem('cool_secret', 123);
sessionStorage.setItem('cool_secret', 123);
Anonymous Poll
23%
A: Forever, the data doesn't get lost.
42%
B: When the user closes the tab.
23%
C: When the user closes the entire browser, not only the tab.
12%
D: When the user shuts off their computer.
DevScrolls
22. How long is cool_secret accessible?
sessionStorage.setItem('cool_secret', 123);
sessionStorage.setItem('cool_secret', 123);
Answer: B
The data stored in sessionStorage is removed after closing the tab.
If you used localStorage, the data would've been there forever, unless for example localStorage.clear() is invoked.
The data stored in sessionStorage is removed after closing the tab.
If you used localStorage, the data would've been there forever, unless for example localStorage.clear() is invoked.
What's the output?
A: false true false true
B: false true true true
C: true true false true
D: true true true true
const obj = { 1: 'a', 2: 'b', 3: 'c' };
const set = new Set([1, 2, 3, 4, 5]); obj.hasOwnProperty('1'); obj.hasOwnProperty(1); set.has('1');
set.has(1);A: false true false true
B: false true true true
C: true true false true
D: true true true true
DevScrolls
What's the output? const obj = { 1: 'a', 2: 'b', 3: 'c' }; const set = new Set([1, 2, 3, 4, 5]); obj.hasOwnProperty('1'); obj.hasOwnProperty(1); set.has('1'); set.has(1); A: false true false true B: false true true true C: true true false true D: true true true true
Answer: C
All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why obj.hasOwnProperty('1') also returns true.
It doesn't work that way for a set. There is no '1' in our set: set.has('1') returns false. It has the numeric type 1, set.has(1) returns true.
All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why obj.hasOwnProperty('1') also returns true.
It doesn't work that way for a set. There is no '1' in our set: set.has('1') returns false. It has the numeric type 1, set.has(1) returns true.
25. What's the output?
const obj = { a: 'one', b: 'two', a: 'three' }; console.log(obj);
const obj = { a: 'one', b: 'two', a: 'three' }; console.log(obj);
Anonymous Poll
30%
A: { a: "one", b: "two" }
17%
B: { b: "two", a: "three" }
17%
C: { a: "three", b: "two" }
35%
D: SyntaxError
DevScrolls
25. What's the output?
const obj = { a: 'one', b: 'two', a: 'three' }; console.log(obj);
const obj = { a: 'one', b: 'two', a: 'three' }; console.log(obj);
Answer: C
If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
Anonymous Poll
55%
A: true
18%
B: false
27%
C: it depends
27. What's the output?
for (let i = 1; i < 5; i++) { if (i === 3) continue; console.log(i); }
for (let i = 1; i < 5; i++) { if (i === 3) continue; console.log(i); }
Anonymous Poll
16%
A: 1 2
42%
B: 1 2 3
39%
C: 1 2 4
3%
D: 1 3 4