Interview - Javascript

javascript
interview

https://medium.com/javascript-scene/master-the-javascript-interview-what-s-the-difference-between-class-prototypal-inheritance-e4cd0a7562e9

What is wrong with this JavaScript loadSubFrame function?

function loadSubFrame(url) {
    var ifr = document.getElementById('myIframe');
    if (! ifr)  {
        ifr = document.createElement("iframe");
        ifr.setAttribute('id', 'myIframe');
        document.body.appendChild(ifr);
    }
    ifr.setAttribute('src',url);
}

Questions that does not requires us to show the candidate an example:

  • Explain how to achieve encapsulation. Give an example of creating a class with a public and private methods, as well as public and private variables.
  • How do you change the style of an element using JavaScript?
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License