Top Tricky JavaScript Interview Questions and Answers




Cracking JavaScript coding Interview by learning difficult JavaScript interview Questions. commonly Asked JavaScript Interview Questions.

Please be my patreons on patreaon
* https://www.patreon.com/techsith

Follow me for technology updates
* https://facebook.com/techsith
* https://twitter.com/techsith1

Help me translate this video.
* http://www.youtube.com/timedtext_video?ref=share&v=3qnrouysbG8
Note: use https://translate.google.com/ to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.

Original source


37 responses to “Top Tricky JavaScript Interview Questions and Answers”

  1. If a programmer asks this "trick question" in an interview, I get up and leave.
    All to the fact that NO ONE will dare write this type of shit and commit this code, it's unreadable, unrelated and confusing, if you would like to return (-1) from your array, there are a myriad of SIMPLE AND READABLE ways to do it.
    The only thing I could think he's trying to gain out of this is him trying to show me that he knows how to be a good QA, nothing more.

  2. Excelent video! The only thing is that the one with the iife, if you console log a in the chrome console it gives you [-1: -1] instead of the error you show!….and b it gives 100 indeed…did something changed in the language? Try it in the new chrome!

  3. 05:25
    I don't seem to get it to work by using return a > b.
    Weird thing is that if I return a – b then it works properly. Am I doing something wrong?
    Thank you in advance.

    const arr = [1, 2, 15, 30, 5, 45, 7];

    console.log(arr.sort((a, b) => {
    return a – b;
    }));

  4. For the sorting one, the comparison is not working because the function looks for a number value, not a boolean 🙁

    x.sort((a,b) => (a-b)) works though!

    Thanks for this though and I love your videos

  5. Thank you so much for making the videos and helping the web developers careers.
    For some reason, the sorting of integers with callback didn't work with a<b, b<a, instead works with a-b, b-a.
    console.log(arr.sort((a,b) =>

    {

    return b-a;

    }));

  6. sir , i have one question. Actually i was asked this question in interview. the question is about converting normal javascrpt function to call back function… so question goes like this,…
    function aa(){
    return 1;
    }
    var res = aa();

    so they wanted me to convert above function into call back function.. how to do sir ? plz help

  7. Hi,

    Could you tell me Y this result is coming in my console?
    var i = Number.MIN_VALUE;
    console.log(i);
    console.log(i+i);
    console.log(i-i);
    console.log(i*i);
    console.log(i/i);

    VM173:2 5e-324
    VM173:3 1e-323
    VM173:4 0
    VM173:5 0
    VM173:6 1

  8. 11:05 – the weirdest part is if you console.log 17 fives it will return 55555555555555550.
    Shouldn't it have "..60" on the right?
    And console.log(44444444444444444); gives us this: 44444444444444450.
    Doesn't make any sense =)

  9. NaN compared to anything is always false.However, Here comes the interesting stuff (typeof null is an Object and type of Object is also Object. When you do a "==" with both of them, it will return you a false.

Leave a Reply