Javascript Interview Questions PART 5 || Vanilla JS Questions

Tasadduq Ali
3 min readDec 29, 2022

--

First of all, if you are interested in joining our Free session to answer your coding, career questions. Kindly fill out this form to join the community of CODE Culture Pro I am form click on me

Here’s the 5th part of my JavaScript Interview Questions series. If you haven’t seen Part 1 and Part 2 and Part 3 and Part 4 yet, go to my Profile Guides and you will find the series.
If you enjoy this post, please like and share it with others. I will really appreciate it. Also do not forget to follow me on medium to get the notification of daily dose of coding knowledge

Let’s look at more questions you can be asked in JavaScript interviews with their answers.

1. What is the difference between single, double, and backticks quotes?
These three quotes are used to create strings in JavaScript. Single ‘..’ and double “…” quotes have no differences. But backticks `…` does.
Unlike single and double, you can create a multi-line string and interpolate expressions in your string with backticks:

//Code
Const multi = “Hello,~
I am multi-line”~
// not possible with double

Const multi = `Hello, I am multi-line`

Const interpolate = `I am ${1 + 2} years old `

Const interpolate = `I am ${1 + 2} years old `
// not possible with single

2. What are the different ways of writing comments in JavaScript?
In JavaScript, you can create single-line and multi-line comments. Single-line comments are created with the double forward slash // while Multi line Comments are created with an opening forward slash and asterisk /*, and closing asterisk and forward slash */:

/* I am a multi-line comment. Look at me
on three lines haha */

// I am a single-line comment
// I am another single-line comment

3. What is the difference between NULL and UNDEFINED?
Undefined is a default value assigned to variables you declare but do not assign a value
//Code
let number;
console.log(number)
// undefined

Null is a value, that means “nothing”. Think of it like an empty value you can apply to variables.
//Code
let number = null;
console.log(number)
// null

4. Explain how the try…catch…finally statement works.
This statement is used for handling exception errors. The way it works is that you run a code in the try block, and if an error is thrown from it, the code in your catch block will handle it, and the ‘finally’ block (optional) will be executed at the end (whether there is an error or not). Here is an example where we access the variable unavailable that is not defined:
//Code
try {
console. log(unavailable)
} catch(error) {
console.log(error)
} finally {
console.log(“ I’m doing with this block “)
}

// ReferenceError: unavailable is not defined
// I’m doing with this block

If you have any questions just do let me know on my Instagram at https://www.instagram.com/codeculturepro/ or at codeculturepro@gmail.com

--

--

Tasadduq Ali
Tasadduq Ali

Written by Tasadduq Ali

I am MERN Stack developer working in UAE Govt to digitize their massive services. I will help you to become highly skilled Coder 😉

No responses yet