Home Interview Questions and Answers JavaScript Interview Questions and Answers Part-1

javascript1.What is JavaScript?
JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.

The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.

2.Name some of the JavaScript features.
Following are the features of JavaScript −

JavaScript is a lightweight, interpreted programming language.

JavaScript is designed for creating network-centric applications.

JavaScript is complementary to and integrated with Java.

JavaScript is is omplementary to and integrated with HTML.

JavaScript is open and cross-platform.

3.What are the advantages of using JavaScript?
Following are the advantages of using JavaScript −

Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.

Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.

Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.

Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

4.What are disadvantages of using JavaScript?
We can not treat JavaScript as a full fledged programming language. It lacks the following important features −

Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.

JavaScript can not be used for Networking applications because there is no such support available.

JavaScript doesn’t have any multithreading or multiprocess capabilities.

5.Is JavaScript a case-sensitive language?
Yes! JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.

6.How can you create an Object in JavaScript?
JavaScript supports Object concept very well. You can create an object using the object literal as follows −

var emp = {
name: “Zara”,
age: 10

7.How can you read properties of an Object in JavaScript?
You can write and read properties of an object using the dot notation as follows −

// Getting object properties
emp.name // ==> Zara
emp.age // ==> 10
// Setting object properties
emp.name = “Daisy” // <== Daisy
emp.age = 20 // <== 20

8.How can you create an Array in JavaScript?
You can define arrays using the array literal as follows −

var x = [];
var y = [1, 2, 3, 4, 5];

9.How to read elements of an array in JavaScript?
An array has a length property that is useful for iteration. We can read elements of an array as follows −

var x = [1, 2, 3, 4, 5];
for (var i = 0; i < x.length; i++) {
// Do something with x[i]

10.What is a named function in JavaScript? How to define a named function?
A named function has a name when it is defined. A named function can be defined using function keyword as follows −

function named(){
// do some stuff here}

You may also like

Leave a Comment