Top 10 Tricky Javascript Questions often asked by Interviewers

Andreas Sujono
8 min readDec 17, 2022

Top 10 tricky Javascript questions often asked by interviewers. Make sure you know all of them!

If you apply for a Frontend or web developer role, you might be assessed for your javascript skills. There is a lot of JS concept that is quite tricky such as hoisting, closure, data types, asynchronous, and others. Here are some of the most frequently asked and trickiest Javascript Questions:

1) Mutability

In Javascript, we have 7 primitive data types (string, number, bigint, boolean, undefined, symbol, and null). These all are immutable meaning that once a value is assigned, we cannot modify them, what we can do is reassign it to a different value (different memory pointer). The other data types such as Object and Function, on the other hand, is mutable meaning we can modify the value in the same memory pointer.

//Q1
let text = 'abcde'
text[1] = 'z'
console.log(text) //ans: abcde

String is immutable, so once assigned to a value, you cannot change it to a different value. What you can do is reassign it. Remember that changing value and reassigning to another value is different

//Q2
const arr = [1,2,3]
arr.length = 0
console.log(arr) //ans: []

--

--

Andreas Sujono

A Full Stack Developer with 5 years of working experience, Web2 and Web3 Enthusiast, twitter: @AndreasSujono2