Course Content

Course Content

Interview Questions

Interview Questions

Hello guys, welcome to our series in JavaScript which is designed solely for web designing. Today’s segment is about interview questions in JavaScript. When you apply for jobs based on what you learnt in this course, there are two possibilities, you are either a fresher or an experienced professional in JavaScript or web designing and you’re applying for a role related to JavaScript. In today’s segment in interview questions we will cover both these scenarios. The questions that are asked at a fresher level and The questions that are asked at an experienced level. However it does not mean that these questions are the only ones that can be asked in the interview. We have selected a few questions that have the highest probability of being asked.

understood guys ! Okay !

(01/26)

So let us start today’s session, the first question is

“What are the different data types present in javascript ?”

It means what are the different data types available in JavaScript. When you have knowledge about C, which is taught in the very first year of college, if you know C and javascript, it is possible that you will mix both these languages. Means you know “C” and you remember “C”s data type. you know javascript, you remember javascript data type. If asked about the javascript, you might get confused, and it is possible that you answer that data type, which is in “C” but not in javascript.

To prevent that from happening, remember this answer well, the answer is…(pause 3 seconds ) JavaScript basically has two types of data types, primitive and non primitive.

Primitive includes string… number…Boolean… etc. etc…Not necessary, that these three only, 

There are more but in our course we used these three to run the programs. so we can remember these 3, for example string,

You can elaborate them further. like

“It represents a series of characters and is written with quotes. A string can be represented using a single or a double quote “

Now, number..

Number holds all the decimal values. Boolean holds all the logical values like true or false.Boolean is mostly used for conditional testing. Boolean values can be true or false.

Then we have the non primitive type, in that we have object and array.

We will consider object and array as a data type because the object holds collection of data and array holds the ordered list. means single type data types but it holds ordered lists.

If you answer this question completely you will make a good impression because the interviewer will think you have a deep knowledge of the software as you have elaborated the simplest question. You should represent simple questions with elaboration.

Make sure to not go on and on and bore the interviewer. you should keep that in mind. you should build a habit to give answers to the point.

your answer always should be to the point but you must add a little description. It really matters how you speak. Not much, other wise interview time will extend, In limited words, you should explain what you are talking about, you have ample knowledge about that.

The right amount of words that doesn’t impact on the duration of the interview while reflecting your knowledge. This was our first question. It will be enough, if you will answer how many data types there are ? What are the data types, what are their uses ? and If you answer in a similar manner, that will be enough.

The second question is,

“explain hoisting in Javascript “

There is a slight possibility that a fresher can be asked this question but at an experienced level there are a lot more chances to be asked this question. I have answered this question in my interviews and I have asked this question while conducting interviews. Hoisting is a commonly asked question.

you can answer of hoisting this way,

The answer is,

“hoisting is a default behaviour of javascript where all variable and function declarations are moved on top”

It means if I have assigned a value already, and later I’m trying to define a variable. For example, Var ..then my variable’s name, hoisted variable. But, I have assigned the value before defining it. So internally, what is the execution time ? This statement, this line, has been sent to the top, while executing, this line will execute first and then these two lines will be executed. It means you can use the variable and later initialise it. This is a logical question. JavaScript gives you this facility that other programming languages don't give. you have to initialize the variable first and then you can use it. But here initialisation can be done before declaration. And that is called hoisting.

After the hoisting, The next question is,

“difference between double equals to and triple equal to operators.

So what happens in double equals operators? and what happens in triple equals operators?

We are asked the difference. Like I had mentioned before they check the value and it uses the width type.

the answer of that is like this,

“both are comparison operators”

So the answer is both of them compare values but the difference is double equals only checks the value but triple equals compares both. triple equals check values as well as type.

here, only the value will be checked means two equal to two, or if it is written x is equal to two, then, it will check if X’s value is two or not.

When I write x=2 in quotes, then what it becomes ? two becomes a string. So I have to check if 2 is an integer and I also have to check if it is a string. The same example is given below,

var x is equal to two and var y is equal to 2

the first one being a number and the second one being a string. So, now If i write x equal to equal to y , So The double equals says it’s true, because it checks only value but the triple equal says it’s false, because here type is numeric and and here it is a string. So the difference is double equals only for value and triple equals value with type. This is a question asked at an experienced level.

okay we will move forward to the next question,

The next question is,

“Is javascript a statically typed or a dynamically typed language ? “

The answer is, JavaScript is a dynamically typed language. Why is JavaScript a dynamically typed language? JavaScript is dynamic, Because if we assign a value to a variable for example var a equal to 23 and if I assign the same variable to another value like Hello world it means I defined the same variable twice with two different values. First value being a number and the second one being a string. It means I am changing the values that have been held in variables. That means during the execution I can change the value that has been held in the variable. The programming language that allows you to change data type during execution like I have changed number to string or i have changed string to boolean, So the programming language that allows this change during the execution of program, we call them dynamically typed language. If a language does not allow this, means to allow single variable different types values, it is called a statically typed language. That means if it allows then, dynamically, and if it doesn’t allow then static. 

This question can be asked to experienced people, but it can also be asked to freshers.

This is a question that can be asked at both a fresher and experienced level.

Now, we will move ahead to the next question.

The next question is,

“What is scope?”

When we covered this topic, I mentioned that scope is a very important topic in variable declaration. So, This is also a question that can be asked at both a fresher and experienced level. 

You can answer about scope like this,

The answer is,

“Scope in javascript, determines the accessibility of variables and functions at various parts in one’s code.” 

It means if I have written a block, for example I have taken a function and I have started the function with curly braces and I closed it, the way I write the variable determines if it is accessible within the limits of a function or outside. If it is within the limits of function then the scope is locally accessible variable and if the variable is accessible throughout the program it is called globally accessible variable. The scope is now global.

So, here in second line,

“In general terms, the scope will let us know at a given part of code, what are the variables and functions that we can or can not access.”

That means which variable I can use and which variable I can not use. that defines with the help of scope.

(10/29)

we will move forward to our next question,

The next question is,

What is a dome ?

This is a very very very important question that will definitely be asked. If you appear for an interview on java script then, what is the DOM ? this question will be asked 100 percent.

you can answer like this,

“DOM stands for document object model.”

The answer is to start by always telling the full form.

Second,

“DOM is a programming language interface for HTML and XML documents.”

Whenever you write a program, in which hierarchy, in which structure your elements will be placed, is defined by DOM.

“when the browser tries to render a HTML document, it creates an object based on the HTML document called DOM”

It means DOM is the object that holds all the elements placed in the document. and in the browser.

When the program creates elements one by one the object is the DOM. What can we do with DOM? We can manipulate or change various elements inside the HTML document. That means we can manipulate or change various elements and we can play dynamically. These changes we can do with the help of DOM.

Now, let’s move forward to the next question.

The next question is,

“What is the difference between let and var ?”

This is a very commonly asked question. It will definitely be asked to a fresher. There are chances of this being asked at an experienced level too. What is the difference between let and var, we can understand this through the table. Let is introduced in ES6. And var is available from the beginning which means when JavaScript came into the market, since then var was used to declare variables.

Later to define scoping let was introduced. So var was already there and let was added later.

for var “it has a function scope”

Var has a function scope which means it can be used throughout and within a function.

“Let, it has a block scope.”

It means curly braces are opened and closed, after this variable introduced by let will not be used. That means curly braces open and curly braces closed. They will only be accessible within the braces. Out of the curly braces, variables initialized through let, won’t be used.

But var can be used to access it outside the curly braces also if it is globally defined. Else we use another globally defined variable throughout the program. We have learnt hoisting, Hoisting is only possible with variables defined with var.

“variable will be hoisted “

If I define the same thing with let, It is not possible with variables defined with let.

“hoisted but not initialized”

 If you design a let variable you cannot perform hoisting. It is mandatory to use var. This is a mandatory question even for the experienced.

Now let’s move forward to the next question,

 8th question…the question is,

What is a cookie ?

Since we make client related programs in JavaScript, and if you’re going in the direction of website design you will definitely need a cookie. you must have knowledge about cookie..okay

If it is a dynamic website then you have been obliged to keep details of users.

So, it can be asked, ``What is a cookie ?

So there is a 50-50 chance of being asked about this for both levels. It is not like that cookie’s will be asked but, we should prepare for that.

So, what is a cookie ?

We have learnt how to initialize cookies, how it works. how to delete cookie,

We have learnt everything about cookies in our module in JavaScript. You can answer this question like this,

you can answer of this question like this,

“A cookie is a piece of data that is stored on your computer to be accessed by your browser.Cookies are saved as key or value pairs”

It means it is part of data that is stored in your data that is used in the browser. plus, It is only defined in key value pairs. If you mention key value pairs in your answer it will be considered as a very good response. How to initialise a cookie will be explained well with this term. You have to use the term key value pairs to talk about initialisation. For example,

document dot cookie equal to username equal to john

It means, here ..document dot cookies, that means , I’m initialising a cookie in which, the key is username and the value is John. So whenever I need to use a document like, I want to do a task that is related to user name, so at that time I want to use this information, I will do it with the help of the information stored in the cookie.

so, what is a cookie ?

it has a 50 -50 percent chance, it can be asked or it can not be asked.

let’s move forward to our next question,

The next question is,

How do you delete a cookie ?

If you are asked anything about cookies, the chances of being asked this question increase. The chances are more for this question. We have learnt all the ways to delete a cookie in the module. We have learnt each and every method to delete cookies in our modules. Okay ! In this module, you can learn everything regarding cookies in detail.

You can answer it like this.

“you can delete cookie by setting the expiry date as a passed date “

It means you can add a cookie expire date, here it is written expires, you just need a date that has been passed and your cookie will be deleted.

now here it is written,

“you don't need to to specify a cookie value in this case “

For example,

in the document dot cookie , here you can add the value or not there will not be a problem even if it is an empty cookie.

If you want to delete it, you will add the expired attribute to it and add a past date. Clear on how to delete it?

now let’s move forward to the last question,

(17/35)

Last question is,

“What are the events ? ”

If you are applying for website making or web design and are interviewed, events are important. In that interview, you can be asked ‘ what are the events “?

Because we use events to make the websites dynamic. and the interviewer asked you this question, If you answer this question it will indicate that you know how to make websites dynamic.

This is why event questions will be asked. You can answer the question like this.

“Events are things that happens to HTML elements”

It means what can be done with HTML elements is defined by events. For example we click elements and bring the cursor on element, press a key on element etc..etc..etc. All these things are called events.

‘’when javascript is used in HTML pages”

That means we use JavaScript in HTML events.

“javascript can react on these events”

which means HTML and CSS don’t react with these things. JavaScript reacts to these things. For example clicking, hovering etc. etc etc..

“Some of the examples of events are,”

we have events such as,

 “the web page finished loading”, the event for this is Onload.

“Input field was changed”, that means input’s value has been changed, its event is change/onchange.

“Button was clicked” Event for button was clicked is onclick. All these are different events. There are other events like onclick…onblur..on double click…on mouse enter…on mouse leave etc. etc.. etc.. You can mention these to elaborate the answer.

JavaScript interview questions for web designing or website making ends here. Like I said there are other questions that can be asked in an interview, I repeat this, there are other questions as well. We have tried to cover a few of them. If you have successfully completed this course you can easily answer any questions that come your way. We have gone into some of those questions in this segment.

If you have any queries or comments, click the discussion button below the video and post there. This way, you will be able to connect to fellow learners and discuss the course. Also, Our Team will try to solve your query.

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere