Interview Questions

  • View all interview questions
  • blank
  • 10 common JavaScript interview questions
    1How would you check if a number is an integer?
    Answer

    You need to be a member to see the answers.

    2What will the following code output?
    (function() {
      var a = b = 5;
    })();
    
    console.log(b);
    Answer

    You need to be a member to see the answers.

    3Write a function that would allow you to do this.
    multiply(5)(6);
    Answer

    You need to be a member to see the answers.

    4When would you use the bind function?
    Answer

    You need to be a member to see the answers.

    5What does "use strict" do?
    Answer

    You need to be a member to see the answers.

    6What is the difference between == and ===?
    Answer

    You need to be a member to see the answers.

    7How would you add your own method to the Array object so the following code would work?
    var arr = [1, 2, 3, 4, 5];
    var avg = arr.average();
    console.log(avg);
    Answer

    You need to be a member to see the answers.

    8Explain what a callback function is and provide a simple example.
    Answer

    You need to be a member to see the answers.

    9What will the following code output?
    0.1 + 0.2 === 0.3
    Answer

    You need to be a member to see the answers.

    10How would you create a private variable in JavaScript?
    Answer

    You need to be a member to see the answers.

    Become a Premium Member

    With our large collection of challengs, tutorials, and solutions, we make it easy for you to become a better coder, prepare for interviews, and learn new skills from more experienced coders.

    “Also important to try coding in nonstructured or semistructured environments to see if you like it. Coderbyte really helped me.“ ― Jeff Ruder
    • 200+ Coding Challenges
    • Mock Interview Questions
    • 500,000+ Code Solutions
    • Algorithm Tutorials
    • Interview Prep Courses
    mrdaniel published this on 11/24/15 | javascript, bootcamp, App Academy, Codesmith, Fullstack Academy, Hack Reactor
    Comments
  • +
  • 12
  • -
  • Very helpful questions!
  • +
  • 2
  • -
  • For the last question, why can't you just return priv and then console.log(func()); like this
    function func() {
      var priv = "secret code";
      return priv;
    }
    
    console.log(func());
    
    Login to submit a comment