SlideShare a Scribd company logo
2
Most read
3
Most read
Javascript Viva Questions
1) What is JavaScript?
Ans:JavaScriptisascriptinglanguage mostoftenusedforclient-side webdevelopment.
2) What is the difference betweenJavaScriptand Jscript?
Ans:BothJavaScriptandJscriptare almostsimilar.JavaScriptwasdevelopedbyNetscape.Microsoft
reverse engineeredJavascriptandcalleditJScript.
3) How do we add JavaScript onto a webpage?
Ans:There are several wayforaddingJavaScriptona webpage,butthere are twoways whichare
commonlyusedbydevelopers
If your scriptcode isveryshort andonlyfor single page,thenfollowingwaysare the best:
a) You can place <script type="text/javascript">taginside the <head>element.
Code
Collapse |Copy Code
<head>
<title>Page Title</title>
<script language="JavaScript"type="text/javascript">
var name = "VikasAhlawta"
alert(name);
</script>
</head>
b) If yourscript code is verylarge,thenyoucan make a JavaScriptfile andaddits pathin the
followingway:
Code
Collapse |CopyCode
<head>
<title>Page Title</title>
<script type="text/javascript"src="myjavascript.js"></script>
</head>
4) Is JavaScript case sensitive?
Ans:Yes!
A functiongetElementByIdisnotthe same asgetElementbyID.
5) What are the typesused in JavaScript?
Ans:String,Number,Boolean,Function,Object,Null,Undefined.
6) What are the booleanoperators supportedby JavaScript? And Operator: &&
Or Operator:||
NotOperator:!
7) What is the difference between“==” and“===”?
Ans:
“==” checksequalityonly,
“===” checksforequalityaswell asthe type.
8) How to access the value of a textbox usingJavaScript?
Ans:ex:-
Code
Collapse |CopyCode
<!DOCTYPE html>
<html>
<body>
Full name:<inputtype="text"id="txtFullName"
name="FirstName"value="VikasAhlawat">
</body>
</html>
There are followingwaystoaccessthe value of the above textbox:
Copy Code
var name = document.getElementById('txtFullName').value;
alert(name);
or:
we can use the oldway:
Copy Code
document.forms[0].mybutton.
var name = document.forms[0].FirstName.value;
alert(name);
Note:Thisusesthe "name"attribute of the elementtolocate it.
9) What are the ways of making comments inJavaScript?
Ans:
Collapse |CopyCode
// isusedfor line comments
ex:- varx=10; //commenttext
/*
*/ isusedforblockcomments
ex:-
Collapse |CopyCode
var x= 10; /* this is
blockcommentexample.*/
10) How will you get the Checkboxstatus whetherit is checkedor not?
Ans:
Collapse |CopyCode
var status= document.getElementById('checkbox1').checked;
alert(status);
will returntrue or false.
11) How to create arrays in JavaScript?
Ans:There are twowaysto create array inJavaScriptlike otherlanguages:
a) The firstway to create array
Declare Array:
Code
Collapse |CopyCode
var names= newArray();
AddElementsinArray:-
names[0] = "Vikas";
names[1] = "Ashish";
names[2] = "Nikhil";
b) This isthe secondway:
Collapse |CopyCode
var names= newArray("Vikas","Ashish","Nikhil");
12) If an array with name as "names" contain three elements,thenhowwill you print the third
elementofthis array?
Ans:Printthirdarray elementdocument.write(names[2]);
Note:- Arrayindex startswith0.
13) How do you submit a form using JavaScript?
Ans:Use document.forms[0].submit();
14) What doesisNaNfunction do?
Ans:It returnstrue if the argumentisnot a number.
Example:
Code
Collapse |CopyCode
document.write(isNaN("Hello")+"<br>");
document.write(isNaN("2013/06/23")+ "<br>");
document.write(isNaN(123)+"<br>");
The outputwill be:
Collapse |CopyCode
true
true
false
15) What isthe use of Math Objectin JavaScript?
Ans:The mathobjectprovidesyoupropertiesandmethodsformathematical constantsand
functions.
ex:-
Code
Collapse |CopyCode
var x = Math.PI; //ReturnsPI
var y = Math.sqrt(16);// Returnsthe square rootof 16
var z = Math.sin(90); Returnsthe sine of 90
getElementById(“myText”).className =“anyclass”;

More Related Content

PPTX
constructors in java ppt
PPTX
Inheritance in java
PPTX
Features of java
PPTX
Java script
PPTX
Java Server Pages(jsp)
PPTX
Python Exception Handling
PPTX
Tcp/ip server sockets
PPTX
Clipping in Computer Graphics
constructors in java ppt
Inheritance in java
Features of java
Java script
Java Server Pages(jsp)
Python Exception Handling
Tcp/ip server sockets
Clipping in Computer Graphics

What's hot (20)

PDF
Introduction to Java Programming
PPTX
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
PDF
C++ OOPS Concept
PPTX
OOPS In JAVA.pptx
PPTX
Arrays in Java
PDF
Arrays in Java
PPTX
Interface in java
PPT
Oops in Java
PPTX
Typescript ppt
PPT
Clipping
PPTX
Java script array
ODP
Datatype in JavaScript
PPTX
Applets in java
PPTX
Core java complete ppt(note)
PPTX
Inheritance in c++
PDF
Python exception handling
PDF
Abstraction
PPTX
Introduction to python for Beginners
PPTX
Introduction about Full stack Development
PPT
Exception Handling in JAVA
Introduction to Java Programming
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
C++ OOPS Concept
OOPS In JAVA.pptx
Arrays in Java
Arrays in Java
Interface in java
Oops in Java
Typescript ppt
Clipping
Java script array
Datatype in JavaScript
Applets in java
Core java complete ppt(note)
Inheritance in c++
Python exception handling
Abstraction
Introduction to python for Beginners
Introduction about Full stack Development
Exception Handling in JAVA
Ad

Similar to Javascript viva questions (20)

PPT
Java Script ppt
PPTX
introduction to java scriptsfor sym.pptx
PPT
Presentation JavaScript Introduction Data Types Variables Control Structure
PPT
Java Script
PDF
Java Script
PPT
JavaScript ppt for introduction of javascripta
PDF
05 JavaScript #burningkeyboards
PDF
JavaScript(Es5) Interview Questions & Answers
PPTX
Java script
PPTX
JavaScripts & jQuery
PDF
Client sidescripting javascript
PPTX
Javascript interview questions and answers
PPTX
Java script
PPTX
gdscWorkShopJavascriptintroductions.pptx
PDF
javascriptPresentation.pdf
PPTX
1-JAVA SCRIPT. servere-side applications vs client side applications
PDF
JavaScript Interview Questions with Answers
PPTX
Lecture 5 javascript
PPTX
Java script
PPTX
CSC PPT 12.pptx
Java Script ppt
introduction to java scriptsfor sym.pptx
Presentation JavaScript Introduction Data Types Variables Control Structure
Java Script
Java Script
JavaScript ppt for introduction of javascripta
05 JavaScript #burningkeyboards
JavaScript(Es5) Interview Questions & Answers
Java script
JavaScripts & jQuery
Client sidescripting javascript
Javascript interview questions and answers
Java script
gdscWorkShopJavascriptintroductions.pptx
javascriptPresentation.pdf
1-JAVA SCRIPT. servere-side applications vs client side applications
JavaScript Interview Questions with Answers
Lecture 5 javascript
Java script
CSC PPT 12.pptx
Ad

More from Vipul Naik (6)

DOCX
Servlet viva questions
DOCX
Jsp viva questions
DOCX
Xml viva questions
DOCX
Java questions for viva
DOCX
Html viva questions
PPT
Chapter 6 intermediate code generation
Servlet viva questions
Jsp viva questions
Xml viva questions
Java questions for viva
Html viva questions
Chapter 6 intermediate code generation

Recently uploaded (20)

PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Institutional Correction lecture only . . .
PPTX
Cell Types and Its function , kingdom of life
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Insiders guide to clinical Medicine.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Institutional Correction lecture only . . .
Cell Types and Its function , kingdom of life
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Insiders guide to clinical Medicine.pdf
PPH.pptx obstetrics and gynecology in nursing
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Classroom Observation Tools for Teachers
master seminar digital applications in india
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Pre independence Education in Inndia.pdf
Cell Structure & Organelles in detailed.
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

Javascript viva questions

  • 1. Javascript Viva Questions 1) What is JavaScript? Ans:JavaScriptisascriptinglanguage mostoftenusedforclient-side webdevelopment. 2) What is the difference betweenJavaScriptand Jscript? Ans:BothJavaScriptandJscriptare almostsimilar.JavaScriptwasdevelopedbyNetscape.Microsoft reverse engineeredJavascriptandcalleditJScript. 3) How do we add JavaScript onto a webpage? Ans:There are several wayforaddingJavaScriptona webpage,butthere are twoways whichare commonlyusedbydevelopers If your scriptcode isveryshort andonlyfor single page,thenfollowingwaysare the best: a) You can place <script type="text/javascript">taginside the <head>element. Code Collapse |Copy Code <head> <title>Page Title</title> <script language="JavaScript"type="text/javascript"> var name = "VikasAhlawta" alert(name); </script> </head> b) If yourscript code is verylarge,thenyoucan make a JavaScriptfile andaddits pathin the followingway: Code Collapse |CopyCode <head> <title>Page Title</title> <script type="text/javascript"src="myjavascript.js"></script> </head> 4) Is JavaScript case sensitive? Ans:Yes! A functiongetElementByIdisnotthe same asgetElementbyID. 5) What are the typesused in JavaScript? Ans:String,Number,Boolean,Function,Object,Null,Undefined. 6) What are the booleanoperators supportedby JavaScript? And Operator: && Or Operator:|| NotOperator:! 7) What is the difference between“==” and“===”? Ans: “==” checksequalityonly, “===” checksforequalityaswell asthe type. 8) How to access the value of a textbox usingJavaScript?
  • 2. Ans:ex:- Code Collapse |CopyCode <!DOCTYPE html> <html> <body> Full name:<inputtype="text"id="txtFullName" name="FirstName"value="VikasAhlawat"> </body> </html> There are followingwaystoaccessthe value of the above textbox: Copy Code var name = document.getElementById('txtFullName').value; alert(name); or: we can use the oldway: Copy Code document.forms[0].mybutton. var name = document.forms[0].FirstName.value; alert(name); Note:Thisusesthe "name"attribute of the elementtolocate it. 9) What are the ways of making comments inJavaScript? Ans: Collapse |CopyCode // isusedfor line comments ex:- varx=10; //commenttext /* */ isusedforblockcomments ex:- Collapse |CopyCode var x= 10; /* this is blockcommentexample.*/ 10) How will you get the Checkboxstatus whetherit is checkedor not? Ans: Collapse |CopyCode var status= document.getElementById('checkbox1').checked; alert(status); will returntrue or false. 11) How to create arrays in JavaScript? Ans:There are twowaysto create array inJavaScriptlike otherlanguages:
  • 3. a) The firstway to create array Declare Array: Code Collapse |CopyCode var names= newArray(); AddElementsinArray:- names[0] = "Vikas"; names[1] = "Ashish"; names[2] = "Nikhil"; b) This isthe secondway: Collapse |CopyCode var names= newArray("Vikas","Ashish","Nikhil"); 12) If an array with name as "names" contain three elements,thenhowwill you print the third elementofthis array? Ans:Printthirdarray elementdocument.write(names[2]); Note:- Arrayindex startswith0. 13) How do you submit a form using JavaScript? Ans:Use document.forms[0].submit(); 14) What doesisNaNfunction do? Ans:It returnstrue if the argumentisnot a number. Example: Code Collapse |CopyCode document.write(isNaN("Hello")+"<br>"); document.write(isNaN("2013/06/23")+ "<br>"); document.write(isNaN(123)+"<br>"); The outputwill be: Collapse |CopyCode true true false 15) What isthe use of Math Objectin JavaScript? Ans:The mathobjectprovidesyoupropertiesandmethodsformathematical constantsand functions. ex:- Code Collapse |CopyCode var x = Math.PI; //ReturnsPI var y = Math.sqrt(16);// Returnsthe square rootof 16 var z = Math.sin(90); Returnsthe sine of 90 getElementById(“myText”).className =“anyclass”;