JavaScript Interview Questions that made me think — Do I really know JavaScript? — Part 1

javascript tricky interview questions

Photo by Rahul Mishra on Unsplash
{name: “Lydia”} // age won’t be included. Because property defined with defineProperty are non enumerable by default.
false // delete operator only deletes a key in object
true // when we don't use any declaration before any variable, it will be treated as a global variable, and will be added as deletable entity in window object.
[ { name: "Noren Red"} ] Initially I thought it will log [ null ] because we have initialised person with nullBut in reality, we are only setting new reference to person variable. Previous reference will be used in members arrayIn Short, { name: "Noren Red"} lives in some memory space whose address is X201and this is how referencing is workinglet person = X201
const members = [ X201 ]
person = null
Silver Surfer Because when we return a property, the value of the property is equal to the returned value, not the value set in the constructor function.

With the padStart method, we can add padding to the beginning of a string.

The value passed to this method is the total length of the string together with the padding.
The string "Silver Surfer" has a length of 13. name.padStart(14) inserts 1 space at the start of the string, because 13 + 1 is 13. If the argument passed to the padStart method is smaller than the length of the array, no padding will be added.
777If we pass string and number combination to parseInt, what parseInt does is, it check at which position wrong datatype is getting started, if value before the wrong datatype is a valid number, it will return the valid number.
1 2 and undefined 3 and undefined 4 
If we don't pass initial value, then by default x will be first value of array, and y will be second value of array.
one - ["", " is ", " years old"]
two - Thor
three - 1000
one - ["hey there, are you amazed"]
two - undefined
three - undefined
If we use tagged template literals, the value of the first argument is always an array of the string values.The remaining arguments get the values of the passed expressions!
function // Classes in JS are functions under the hood



A passionate iOS Developer since 2014.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store