DEV Community

Top 26 JavaScript Interview Questions I Wish I Knew

Alex 👨🏼‍💻FullStack.Cafe on September 24, 2018

According to Stack Overflow’s Annual Survey of 2018, JavaScript becomes the most commonly used programming language, for the six years in a row. L...
Collapse
 
leo profile image
Leonardo Galante •

Great article!

For "Q11: How would you check if a number is an integer?" I recommend using:

function isInt(num) {
  return Number.isInteger(num)
}

console.log(isInt(4)); // true
console.log(isInt(12.2)); // false
console.log(isInt(0.3)); // false
Enter fullscreen mode Exit fullscreen mode
Collapse
 
6temes profile image
Daniel •

As far as you are not tageting IE.

caniuse.com/#search=isInteger

Collapse
 
olu_semola profile image
Oladoyin Falana •

i would like more of the articles that address performance of javascript under the hood like this one.

Collapse
 
webdevinci profile image
webdevinci •

Q6: Explain Null and Undefined in JavaScript
Bonus point pointing out Null is an object, it's null-ness still takes up memory

Collapse
 
dukemai profile image
dukemai •

nice, I was surprised most by the question 0.1+0.2===0.3.

Collapse
 
syedmeesamali profile image
syedmeesamali •

This is what always haunts me and i'm not sure if that's the case with any other language? I used Python, C, C++ and VBA but such stuff is unseen there.

Collapse
 
hassam7 profile image
Hassam Ali •

it's same in Python, C and C++

Thread Thread
 
delavarimohsen profile image
Mohsen •

it's same in c# too but in goLang 0.1 + 0.2 == 0.3 is true :)

Collapse
 
zcs19871221 profile image
zcs1 •

hi,it is a good article.but it has a problem:
Q20:
for your function ,it seemed wrong:
isIsomorphic('sad', 'egg') !== isIsomorphic('egg', 'sad')
my function:

function isIsomorphic(stra, strb) {
if (typeof stra === 'string' && typeof strb === 'string') {
    const len = stra.length;
    if (len !== strb.length) {
        return false;
    }
    const mapa = {};
    const mapb = {};
    function countApperTimes(map, pro) {
        map[pro] = map[pro] ? map[pro] + 1 : 1;
    }
    for (let i = 0; i < len; i++) {
        const a = stra[i];
        const b = strb[i];
        countApperTimes(mapa, a);
        countApperTimes(mapb, b);
        if (mapa[a] !== mapb[b]) {
            return false;
        }
    }
    return true;
}
return false;
}
Collapse
 
l0x0s profile image
l0x0s • • Edited

good article! I learned a few things
Q22 is not completely right according to me .
this may refer the context of the definition with the arrow function.
(lexical scoping vs dynamic scoping)

Collapse
 
sd031 profile image
Sandip Das •

It's great article indeed! , I shared in linkedIn and twitter, I am sure this will help javascript developers in their interviews.

Collapse
 
lionroar profile image
Ferris Etanish •

Great article I really needed that quick revision 👍

Collapse
 
alisherohunov profile image
Alisher Okhunov •

very great, I was shocked most by the question 0.1+0.2===0.3.

Collapse
 
realabbas profile image
Ali Abbas •

Great Article. Thank you Dev Alex.👍

Collapse
 
itachiuchiha profile image
Itachi Uchiha •

Great article! Thanks.

Collapse
 
grepliz profile image
Liz Lam •

Excellent and insightful article!

Collapse
 
olu_semola profile image
Oladoyin Falana •

I love this article. nice one!

Collapse
 
sagar profile image
Sagar •

Great article Alex!!

Collapse
 
techdevtools profile image
Devtools Tech •

Nice. Thanks for sharing!

We also post real world frontend interview questions too. Check out devtools.tech/questions/all