SlideShare a Scribd company logo
1 of 3
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

What's hot

Ajax (Asynchronous JavaScript and XML)
Ajax (Asynchronous JavaScript and XML)Ajax (Asynchronous JavaScript and XML)
Ajax (Asynchronous JavaScript and XML)Abdelouahed Abdou
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...Edureka!
 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAndres Baravalle
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JSArno Lordkronos
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slidesSmithss25
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...Edureka!
 

What's hot (20)

Features of java
Features of javaFeatures of java
Features of java
 
Ajax (Asynchronous JavaScript and XML)
Ajax (Asynchronous JavaScript and XML)Ajax (Asynchronous JavaScript and XML)
Ajax (Asynchronous JavaScript and XML)
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Jquery
JqueryJquery
Jquery
 
jQuery
jQueryjQuery
jQuery
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification T...
 

Similar to Javascript viva questions

8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentationJohnLagman3
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
 
Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer0983676660
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksJuho Vepsäläinen
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptKevin Read
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Kevin Read
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015jbandi
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereLaurence Svekis ✔
 
Java script Basic
Java script BasicJava script Basic
Java script BasicJaya Kumari
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsJack Franklin
 
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!PVS-Studio
 
JavaScript Interview Questions with Answers
JavaScript Interview Questions with AnswersJavaScript Interview Questions with Answers
JavaScript Interview Questions with AnswersAK Deep Knowledge
 

Similar to Javascript viva questions (20)

8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
JavaScript Basics with baby steps
JavaScript Basics with baby stepsJavaScript Basics with baby steps
JavaScript Basics with baby steps
 
How I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScriptHow I learned to stop worrying and love embedding JavaScript
How I learned to stop worrying and love embedding JavaScript
 
Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8Embedding V8 in Android apps with Ejecta-V8
Embedding V8 in Android apps with Ejecta-V8
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015
 
Webpack
Webpack Webpack
Webpack
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
Coding the UI
Coding the UICoding the UI
Coding the UI
 
Coding Ui
Coding UiCoding Ui
Coding Ui
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
 
JavaScript Interview Questions with Answers
JavaScript Interview Questions with AnswersJavaScript Interview Questions with Answers
JavaScript Interview Questions with Answers
 
Java scipt
Java sciptJava scipt
Java scipt
 

More from Vipul Naik

Servlet viva questions
Servlet viva questionsServlet viva questions
Servlet viva questionsVipul Naik
 
Jsp viva questions
Jsp viva questionsJsp viva questions
Jsp viva questionsVipul Naik
 
Xml viva questions
Xml viva questionsXml viva questions
Xml viva questionsVipul Naik
 
Java questions for viva
Java questions for vivaJava questions for viva
Java questions for vivaVipul Naik
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questionsVipul Naik
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generationVipul Naik
 

More from Vipul Naik (6)

Servlet viva questions
Servlet viva questionsServlet viva questions
Servlet viva questions
 
Jsp viva questions
Jsp viva questionsJsp viva questions
Jsp viva questions
 
Xml viva questions
Xml viva questionsXml viva questions
Xml viva questions
 
Java questions for viva
Java questions for vivaJava questions for viva
Java questions for viva
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questions
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 

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”;