- ES5
- ES6 (ES6 has another name which is ________)
- ES7 (which is also called ________)
- Typescript: ______/10
- Babel: ______/10
- ESLint: ______/10
- Webpack: ______/10
- Functional Programming: ______/10
- Functional Reactive Programming: ______/10
- Service Worker: ______/10
- GraphQL: _____/10
Array.forEach is not a function
What does he need to get the function working?
8. Give an example where putting a piece of Javascript at the <head>
is better than at the end of the document
9. The website has a Factorial Calculator feature. User inputs 5, click Calculate, then the number 120 is displayed (5! = 120).
function factorial(n) {
if (n === 0) { return 1; }
return n * factorial(n - 1);
}
However when user inputs larger number (like 100) the browser is not responding for a while. Given that we cannot change factorial function, describe how to fix it the lag?
10. The client wants a header on a page that is hidden when user scrolls to the top, but shown if user scrolls down a little bit. The developer does that by registering a handler to window's scroll event like this:
window.addEventListener('scroll', function() {
if (window.pageYOffset <= 10) {
// Hide header
}
else {
// Show header
}
});
But on some machine, scrolling lags because the event fires so many times. Any idea on how to fix this?
11. A website has a section where user can type raw HTML into an <textarea>
. Then clicking on a button View HTML
will display the raw HTML content on the site.
- What can be the security risk here?
- How would you propose to fix it?
12. One of the client's website has a notification feature. If something happens in the backend, the frontend will show notification in real time. One developer thinks of calling an AJAX request after every 30 seconds. Is this a good way or is there an alternative?
13. On the deployment of a new website, all of the Restful APIs fail with code 405 Method-Not-Allowed
.
- The reason of this error is that:
- To fix this, we must:
14. The client wants that, when user logs out of one browser tab, all other opening tabs of that same page on that browser will be notified as well (and show a message, for example). Give an idea on how to do that?
someCalculation(1234); //takes 10 seconds to finish
The writer of this function says that it is idempotent - and is pure
- What is Idemponent
- What is Pure
- What can be done to the function to allow caching of result, so that if we call with the same argument again, it will not re-calculate. (We are not allowed to change the internal of the function
someCalculation
)
someCalculation(1234); //takes 10 seconds to finish
someCalculation(1234); //should return immediately
- Clicking on
<img data-id="2ef72ab" />
, the browser URL will be https://my-portfolio.com/view/2ef72ab. - Clicking on
<img data-id="839acd2 />
, the browser URL will be https://my-portfolio.com/view/839acd2. - The clicked image will be added a class "active", the rest will have the class "active" removed.
- The browser should not perform a reload on image click
What Native HTML API can be used to:
- Get the data-id from the
<img>
element being clicked?
- Add and remove class "active" from the
<img>
being clicked?
- Change browser URL without reload?
17. Explains the result of this code snippet: which alert will be fired first, or something else will happen?
<script type="text/javascript">
document.write('<script type="text/javascript">alert(1);</script>');
alert(2);
</script>
- BEM: ______/10
- SASS: ______/10
- PostCSS: ______/10
- CSS Module: ______/10
- Above the fold: ______/10
- Feature Queries: _____/10
- CSS Grid: _____/10
19. How many CSS ways to hide an element on the screen so that it's not visible and not interactive at all:
21. Supposed the browser screen is 1280 x 655 pixels. What will be the pixel equivalence of those CSS units:
- 1 vh = _____ px
- 1 vw = ______px
- 1 vmin = _____px
- 1 vmax = _____px
.parent .child { background-color: red; }
.child { background: green; }
And with DOM like this
<div class="parent">
<div class="child"></div>
</div>
What will be the background color of div.child?
In CSS, the "strength" of a declaration is called:
.container1 { z-index: 100; }
.container1 .child { z-index: 102; }
.container2 { z-index: 101; }
And the following HTML:
<div class="container1">
<div class="child"></div>
</div>
<div class="container2"></div>
Supposed that the bounding rectangle of div.child
overlaps div.container2
.
- Is
div.child
displayed under or abovediv.container2
?
- What is this property of z-index called?
What does "positioned elements" mean?
- Is 150px away from the top of document.
- When scroll position is from 0px to 150px, the header scrolls normally.
- When scroll position is from 150px to the end of document, the header sticks at the top.
- Describe how to implement this kind of header?
- Can this be solved using only CSS?
26. If we have two divs stacking vertically. The div at the top has margin-bottom of 10px. The div at the bottom has margin-top of 20px.
- What will be the actual margin between them?
- What is this feature of margin called ?
27. The client wants that when user goes to http://example.com#section1, the div#section1
should be highlight. Can this be done via CSS only, and how?
28. The client's website has two sizes: Desktop and Mobile. However when loading Desktop, resources for Mobile (images, video…) are also loaded. Can we prevent loading irrelevant resources by pure CSS only? And how?
- Progressive Web Apps: ______/10
- Domain Sharding: ______/10
- ARIA: ______/10
- Modernizr: _____/10
- A/B Testing: _____/10
- Web Component: _____/10
- HTTP2: _____/10
<a>[email protected]</a>
<a>1900 1001</a>
Our client wants that clicking on the email address should open the respective email client and clicking on the phone number on a phone should open the dial screen. Rewrite the markup to fix this:
31. Supposed you have an <input type="text" />
on the screen. Without using Javascript, make the input focus when page loads.
32. You have a <button>
inside a <form>
element. This button is not the submit button, but when you click on it, the form does a submission. How to fix this?
Advantages of IconFont:
Disadvantages of IconFont:
Advantages of SVG:
Disadvantages of SVG:
35. What is the native HTML way to load the correct image depending on user's device resolution. For example: on iPhone the page should loads a smaller image, and on a desktop the page will load a bigger image.
36. The client's website is https://example.com. Some user have reported that the console shows an error:
Mixed Content: The page at https://example.com was loaded over HTTPS, but requested an insecured XMLHttpRequest endpoint http://example.com/api/get. The request has been blocked; the content must be served over HTTPS.
Why does it happen, and how to fix this issue?
37. Imagine you are a new developer coming to an existing project. On a feature, you load an external library script by using a script tag.
<script src="https://external-libraries.com/script.js"></script>
However the site refuses to load and execute your script. The following was observed in the console:
Refuse to load the script https://external-libraries.com/script.js because it violates the following Content Security Policy directive: script-src self
What is the cause of this error:
How to fix this issue:
For example we have
<link rel="alternate" media="only screen and (max-width: 640px)" href="http://m.example.com/">
What does rel="alternate" do?
Another link
<link rel="canonical" href="http://www.example.com/">
What does rel="canonical" do?
40. Implement a download image feature for your site. When user clicks on a link, the browser automatically downloads a file name "downloadme.jpg"
<a href="/my-site/downloadme.jpg">Click to download</a>
Rewrite the markup to achieve such feature.