Skip to content

Instantly share code, notes, and snippets.

@oleksiilevzhynskyi
Last active December 17, 2021 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleksiilevzhynskyi/6153868 to your computer and use it in GitHub Desktop.
Save oleksiilevzhynskyi/6153868 to your computer and use it in GitHub Desktop.
Quiz: all topics
### Quiz:
1. What is result of next line of code?
typeof null
Answer:
* `null`
* `object`
* `undefined`
2. Which of the following function no exist for string?
* reverse
* replace
* substring
* concat
3. When executed, what value will be alerted to the screen?
function() {
var a = 10;
if (a > 5) {
a = 7;
}
alert(a);
}
Answer:
* 7
* 10
* `null`
* `undefined`
4. Assuming I call these functions in order, what value gets alerted?
var a = 5;
function first() {
a = 6;
}
function second() {
alert(a);
}
Answer:
* 5
* 6
* `null`
* `undefined`
5. There are now two variables with the same name, a. Which one does Javascript pick?
var a = 5;
function() {
var a = 7;
alert(a);
}
Answer:
* 5
* 7
6. When executed, this will pop up three alerts. In order, what are they?
var a = 6;
function test() {
var a = 7;
function again() {
var a = 8;
alert(a); // First
}
again();
alert(a); // Second
}
test();
​alert(a);​ // Third
Answer:
* 8; 6; 7
* 7; 6; 8
* 6; 7; 8
* 8; 7; 6
7. What's alerted to the screen?
function getFunc() {
var a = 7;
return function(b) {
alert(a+b);
}
}
var f = getFunc();
f(5);
Answer:
* `null`
* 5
* 7
* 12
8. In the following example, what is foo aliased to?
(function(foo) {
// What is 'foo' aliased to?
})(this);
Answer:
* `undefined`
* global object (window)
* `null`
* `this`
9. Why do these yield different results? Write down.
'1' + 2 + 3 ; // Equals '123'
3 + 2 + '1'; // Equals '51'
3 + 2 + 1 ; // Equals 6
10. How do these differ?
function foo() {}
// versus
var foo = function() {};
11. Explain how to determine if a variable is an array or an object. Write few examples.
12. In one line of code, how you would make a copy of an array?
13. What’s the result of:
function f() {
var a = 5;
return new Function('b', 'return a + b');
}
consoe.log( f()(1) );
Answers:
* 1
* 6
* undefined
* NaN
* error
14. What’s the result of:
var f = function(x) {
console.log(x)
}
(function() {
f(1);
}())
Answers:
* nothing
* 1
* error
* depends on browser
15. What’s the result of:
function a(x) {
return x * 2;
}
var a;
console.log(a);
Answers:
* error
* 2
* undefined
* body of function
16. What’s the result of:
(function() {
return typeof arguments;
})();
Answers:
* 'object'
* 'array'
* 'arguments'
* 'undefined'
17. What’s the result of:
var f = function g() { return 'test'; };
console.log( typeof g() );
Answers:
* string
* undefined
* function
* error
18. What’s the result of:
console.log (f());
var f = function () { return 1; };
Answers:
* null
* undefined
* 1
* error
19. What’s the result of:
function A() {}
A.prototype.name = 'A';
var a = new A();
var b = new A();
a.name = 'B';
console.log(a.name, b.name);
Answers:
* 'A', 'A'
* 'B', 'A'
* 'B', 'B'
20. What’s the result of:
function A() {}
A.prototype = {
name: 'A';
};
var a = new A();
A.prototype = {
name: 'B'
};
var b = new A();
console.log(a.name, b.name);
Answers:
* 'A', 'A'
* 'A', 'B'
* 'B', 'B'
21. What’s the result of:
function A() {
return 5;
}
var a = new A();
console.log(a);
Answers:
* 5
* Object
* undefined
* body of function
22. What’s the result of:
function A() {
this.name = 'A';
}
var a = A();
console.log(a.name)
Answers:
* 'A'
* TypeError
* Window
* depends on browser
23. What’s the result of:
function A() {}
A.prototype = 5;
var a = new A()
console.log(Object.getPrototypeOf(a));
Answers:
* 'object'
* 5
* 'undefined'
* Error
24. What are the range of heading tags available using HTML?
* <h1> to <h3>
* <h1> to <h6>
* <h1> to <h8>
* <h1> to <h7>
* <h1> to <h9>
25. What is the difference between inline-block and block, inline-block and inline element?
26. Which color is applied to the text in block #my-id if there are next rules:
.my-class{
color: red;
}
#my-class{
color: white;
}
div.my-class{
color: black;
}
div#my-class{
color: green;
}
<div class='my-class' id="my-id">some content</div>
* red
* white
* green
* black
27. Coose correct order. From most importent to less.
1. inline-style
2. id
3. class
4. !important
* 1,2,3,4
* 2,3,4,1
* 4,1,2,3
* 1,3,2,4
28. What is DOM?
29. How to stop event bubbling?
30. How to stop default browser event? (ex.: prevent redirect on click by link)
31. How to create div and insert it to document with vanilla JS?
32. What are data- attributes good for?
33. Explain "hoisting"
34. Explain AJAX. Write example of AJAX call on vanilla JS.
Copy link

ghost commented Dec 17, 2021

نتالعنلعخلفعهفغلغ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment