Java Script Interview Questions and Answers

What is JavaScript?
JavaScript is a scripting language, designed to add interactivity to HTML pages, JavaScript is usually embedded directly into HTML pages, and JavaScript is an interpreted language (means that scripts execute without preliminary compilation) JavaScript is a platform-independent, event-driven, interpreted client-side scripting and programming language developed by Netscape Communications Corp. and Sun Microsystems.
Define JavaScript Variables?

JavaScript is case-sensitive, variable names are case-sensitive. Creating variables in JavaScript is most often referred to as "declaring" variables. You declare JavaScript variables with the var keyword:
Var x;
Var fu='hi';
Var gf=3.45;

What is variable typing in java script?
It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows example i = 10; i = 'stringchar'; This is called variable typing
How do you create an object in JavaScript?
var person = new Object; or var person = {};
Are Java and JavaScript the same?
NO! Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++. JavaScript’s syntax is loosely based on Java
What's relationship between JavaScript and ECMA Script?

ECMA Script is yet another name for JavaScript (other names include Live Script). The current JavaScript that you see supported in browsers is ECMA Script revision 3. Java Script is a scripting language that has been widely accepted for client side web development. However it originated from ECMA standards. ECMA and live scripts are just other names of java script.

What Boolean operators does JavaScript support?
&&, || ,!
What looping structures are there in JavaScript?
For, while, do-while loops
What is the difference between undefined value and null value?
Undefined means a variable has been declared but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value. Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object. Unassigned variables are initialized by JavaScript with a default value of undefined. JavaScript never sets a value to null. That must be done programmatically.

What data types are supported in Java Script?
Number, String, Undefined, null, Boolean
Explain a JavaScript Comments?

Comments can be added to explain the JavaScript, or to make the code more readable.
Single line comments start with //.
Multi line comments start with /* and end with */

What does the tag do?
Displayed the text enclosed within tag when JavaScript is disabled
What is === operator in JavaScript and how it is different from == operator?

=== operator checks for the equality. It gives true when both the compared values are having same value and same data type as === does not perform any type conversion while comparing. 

It is different from == as == does the type conversion while comparing.

What is the difference between JavaScript and Jscript?

Jscript supports more rich set of functionality/commands than the java script, through which ActiveX and local computer can be accessed. These commands are used in an intranet where the connecting computer's configuration is known and they are all being accessed using Internet Explorer. While java script targets unknown machine configuration and Jscript cannot for which java script are suitable for internet which Jscripts are not.

What is the main difference between Client side JavaScript and Server side Java Script? How actually they run on both side?

To state the main difference, JavaScript at the client side does not require a web server to make it run instead it uses the client's processor for this purpose. This eradicates the portability issue. But in server side JavaScript deployment, portability, configuration are major and vast issues and requires a web server to run the script within a page before rendering its output as a response html page.

How can JavaScript make a Web site easier to use?
JavaScript’s run on the client side which saves the server roundtrip time for small processing. It means that it makes web pages more interactive as everything is not required to be submitted at the server. Let’s consider a small clock if controlled by the server then the transmission time will make the clock faulty in this case java script is used.

Latest Updates

Indian Geography

What is the approximate distance between earth and the moon?

Indian History

In which year was the battle of ‘Koregaon Bhima’ fought?

The approach that is very useful in organizing the content in history is.

General Knowledge of India

NITI Aayog stands for _____.

General Knowledge of MP

India’s first Ramayan art museum was established at?

Errors Identification

Read the sentence carefully and choose the option that has an error in it:
The management’s trusted employee was suspected of stealing large sum of money.

Read the sentence carefully and choose the option that has an error in it:
The teacher asked the child to repeat again because he spoke feebly.

Fill in the blank

Fill in the blank with the most appropriate preposition in the given sentence.
Let’s sit _________ the shade of this beautiful tree.

Choose the most appropriate determiner for the given sentence.
________of what he said was very sensible.

Substitution

Choose the option that substitutes the given phrase appropriately.
A work of art made by carving

Correct sentence

Choose the option that best transforms the sentence into its Indirect form:
‘What country do you come from?’ said the police officer.

Alternative Phrase

Choose the option that best explains the highlighted expression:
All human beings have feet of clay.

Fill in the blank

Choose an appropriate modal for the given sentence:
My doctor said that I_____ stop smoking as one of my lungs got infected.

Choose the appropriate prepositions for the given sentence:
My parents have been married ________ forty-nine years, but you can still see the love ________ their eyes.

Choose the appropriate conjunction for the given sentence:
______ it rains, the college will declare the holiday.

Antonyms

Choose the appropriate antonym for the highlighted word in the given sentence.
The family protracted their visit by several days.

Tenses

Choose the appropriate tenses to fill in the blanks in the given sentence:
Please _________ a noise. Ritu __________ to sleep.

Synonyms

Choose the appropriate synonym for the highlighted word in the given sentence.
Does he really expect us to believe such a flimsy excuse?