Member-only story

JavaScript Interview Tips — Implicit Type Conversion

Liu Ting Chun
5 min readJan 24, 2020

--

After attending couple of interviews, I would like to start recording down what I have been asked frequently. I hope it can not only help myself to prepare for future interviews, but also give you a direction about what you may be asked in JavaScript technical interviews.

Final Puzzle Piece Falls Into Place — by lexaarts

Implicit type conversion is a basic JavaScript feature to coerce an unexpected value type to the expected type. In simple, when you console.log('1' + 1) , it shows 11 instead of 2. It is because the engine coverts your number 1 into a string as it expects a string when you use the + operator in a string (which is concatenation instead of addition).

This sounds like a super basic introduction of JavaScript programming, but this is also the tricky point. You don’t need to understand very deeply in this topics to start JavaScript programming, which becomes a blind spot. The questions about this topic are very conceptual. If you haven’t prepared well enough, you will find it very difficult to answer such questions simply by your experience.

First, I would like start with some sample questions that your interviewers may ask.

let o = {};
o[1] = 1;
o['1'] = 2;
console.log(object);
console.log(true + 1);
console.log(true + '1');
console.log(1 + 2 + 3);
console.log('1'…

--

--

Liu Ting Chun
Liu Ting Chun

Written by Liu Ting Chun

Web developer from Hong Kong. Most interested in Angular and Vue. Currently working on a Nuxt.js + NestJS project.

Responses (1)