JavaScript Interview Questions, Answers, and Explanations: JavaScript Certification Review
By equitypress
()
About this ebook
The Ultimate JavaScript Reference & Learning Guide
Over 100 Certification Questions, Answers, and Explanations
One cannot claim fluency as a web developer without advanced knowledge of JavaScript, however, locating user-friendly yet comprehensive sources of reference can be challenging. With JavaScript Interview Questions, Answers, and Explanations: JavaScript Certification Review, you can be in great shape to evaluate a potential job candidate, brush up on skills, or prepare for an interview. This guide will explain trouble shooting, applicability in websites and other applications, new features in 1.7, interactions with the host environment, and common errors. More than just Sun Microsystems documentation and sales pitches, this guide explains JavaScript from the perspective of the web developer so that you can evaluate a candidate or land a position with ease.
Key topics include:
*Changes from 1.6 to 1.7
*Methods of interaction between JavaScript engines and host environments
*Uses for stylizing or designing web based user interfaces
*Security
*Troubleshooting for many of the browsers in common use today, for instance PDAs and mobile phones
Read more from Equitypress
Oracle Ultimate DBA Interview Questions Rating: 5 out of 5 stars5/5C# Interview Questions, Answers, and Explanations: C Sharp Certification Review Rating: 5 out of 5 stars5/5Oracle® Financials Interview Questions: Unofficial Oracle Financials Certification Review Rating: 3 out of 5 stars3/5SAP Security Interview Questions, Answers, and Explanations Rating: 4 out of 5 stars4/5SAPCOOKBOOK Training Tutorials: SAP MM Inventory Management Rating: 4 out of 5 stars4/5The Programmer’s Guide to Microsoft Access Rating: 3 out of 5 stars3/5Unofficial SAP WebDynpro for ABAP Rating: 5 out of 5 stars5/5Cisco Network Administration Interview Questions: CISCO CCNA Certification Review Rating: 5 out of 5 stars5/5SAP Solution Manager Rating: 4 out of 5 stars4/5SAP FICO Company Creation Rating: 4 out of 5 stars4/5SAP IS-Retail Interview Questions, Answers, and Explanations Rating: 3 out of 5 stars3/5Python Interview Questions Rating: 5 out of 5 stars5/5SAPCOOKBOOK Training Tutorials SAP Financials: Accounts Receivable Rating: 4 out of 5 stars4/5TCP/IP Networking Interview Questions, Answers, and Explanations: TCP/IP Network Certification Review Rating: 5 out of 5 stars5/5Oracle Database Security Interview Questions, Answers, and Explanations: Oracle Database Security Certification Review Rating: 0 out of 5 stars0 ratingsCOBOL Programming Interview Questions: COBOL Job Interview Preparation Rating: 5 out of 5 stars5/5SAP R/3 Transaction Codes Unofficial Certification and Review Guide Rating: 4 out of 5 stars4/5PHP Interview Questions, Answers, and Explanations: PHP Certification Review: PHP FAQ Rating: 0 out of 5 stars0 ratingsDB2 Interview Questions, Answers, and Explanations: DB2 Database Certification Review Rating: 0 out of 5 stars0 ratingsPHP mySQL Web Programming Interview Questions, Answers, and Explanations: PHP mySQL FAQ Rating: 4 out of 5 stars4/5PeopleSoft HRMS Interview Questions, Answers, and Explanations Rating: 5 out of 5 stars5/5The Piano Pricer: A Short Guide to Buying, Owning, and Selling Rating: 2 out of 5 stars2/5Baby Girl Names: The Most Popular Baby Girl Names in America from 1900 to Present Rating: 0 out of 5 stars0 ratingsAddison's Disease Patient Advocate Rating: 0 out of 5 stars0 ratingsMicrosoft .NET Interview Questions: MS .NET Certification Review Rating: 0 out of 5 stars0 ratingsEnterpriseOne Interview Questions Rating: 0 out of 5 stars0 ratingsMicrosoft® Dynamics AX® Interview Questions: Unofficial Microsoft Dynamics AX Axapta Certification Review Rating: 0 out of 5 stars0 ratingsLPI Linux Certification Questions: LPI Linux Interview Questions, Answers, and Explanations Rating: 4 out of 5 stars4/5
Related to JavaScript Interview Questions, Answers, and Explanations
Related ebooks
JavaScript Patterns JumpStart Guide (Clean up your JavaScript Code) Rating: 4 out of 5 stars4/5120 Advanced JavaScript Interview Questions Rating: 0 out of 5 stars0 ratings50 Recipes for Programming Node.js Rating: 3 out of 5 stars3/5Mastering JavaScript: The Complete Guide to JavaScript Mastery Rating: 5 out of 5 stars5/5JavaScript Bible Rating: 4 out of 5 stars4/5Quick JavaScript Learning In Just 3 Days: Fast-Track Learning Course Rating: 0 out of 5 stars0 ratings50 Recipes for Programming Angular Rating: 4 out of 5 stars4/5HTML5, JavaScript, and jQuery 24-Hour Trainer Rating: 2 out of 5 stars2/5JavaScript Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsJavaScript: Advanced Guide to Programming Code with JavaScript Rating: 0 out of 5 stars0 ratingsNode.js, JavaScript, API: Interview Questions and Answers Rating: 5 out of 5 stars5/5React and React Native Rating: 4 out of 5 stars4/5JavaScript: Advanced Guide to Programming Code with Javascript: JavaScript Computer Programming, #4 Rating: 0 out of 5 stars0 ratingsGetting Started with React Rating: 0 out of 5 stars0 ratingsLearning AngularJS Animations Rating: 4 out of 5 stars4/5JavaScript: Best Practices to Programming Code with JavaScript: JavaScript Computer Programming, #3 Rating: 0 out of 5 stars0 ratingsReactJS for Jobseekers: The Only Guide You Need to Learn React and Crack Interviews (English Edition) Rating: 0 out of 5 stars0 ratingsMastering JavaScript Single Page Application Development Rating: 0 out of 5 stars0 ratingsHow JavaScript Works Rating: 0 out of 5 stars0 ratingsObject-Oriented JavaScript: Create scalable, reusable high-quality JavaScript applications, and libraries Rating: 3 out of 5 stars3/5JavaScript: Tips and Tricks to Programming Code with Javascript: JavaScript Computer Programming, #2 Rating: 0 out of 5 stars0 ratingsModern JavaScript Applications Rating: 0 out of 5 stars0 ratingsJavaScript: The New Toys Rating: 0 out of 5 stars0 ratingsTest-Driven JavaScript Development Rating: 0 out of 5 stars0 ratingsUnderstanding JavaScript Promises Rating: 0 out of 5 stars0 ratingsLearning jQuery 3 - Fifth Edition Rating: 0 out of 5 stars0 ratingsMastering JavaScript Object-Oriented Programming Rating: 0 out of 5 stars0 ratingsNode.JS Guidebook: Comprehensive guide to learn Node.js Rating: 0 out of 5 stars0 ratings
Reviews for JavaScript Interview Questions, Answers, and Explanations
0 ratings0 reviews
Book preview
JavaScript Interview Questions, Answers, and Explanations - equitypress
Question 1: Image Loop
I have a problem with the codes below:
function curl(a){
var i = 1
if (a.substring(0,7)!='http://' || a.substring(a.length-3,a.length)!='gif')
{
alert(Error
);
}
else
{
document.getElementById('dply').innerHTML='';
for (i = 1; i < 6; i++){
a=a.replace(*n*
,i);
document.getElementById('dply').innerHTML = document.getElementById('dply').innerHTML +
'
'+''+a+'> '+a+'>'+a+'';
}
}
}
text id=url
size=40
value=http://www.eastman.ucl.ac.uk/guide/*n*.gif
>
button onclick=curl(document.getElementById('url').value)
>
Why does the script above not go from 1.gif to 2.gif, 3.gif, 4.gif and 5.gif?
A: When you call the function with the value http://www.eastman.ucl.ac.uk/guide/*n*.gif, the parameter a takes this value.
In the first iteration, when i has the value 1, the statement a=a.replace(*n*
,i); changes the value of a to http://www.eastman.ucl.ac.uk/guide/1.gif.
In the next iterations, when i has the value 2, 3, 4 … the statement a=a.replace(*n*
,i); will do nothing, because the string *n* is no longer part of a. The value of a (http://www.eastman.ucl.ac.uk/guide/1.gif) will remain unchanged.
The script should be:
function curl(a){
var i = 1
if (a.substring(0,7)!='http://' || a.substring(a.length-3,a.length)!='gif')
{
alert(Error
);
}
else
{
document.getElementById('dply').innerHTML='';
for (i = 1; i < 6; i++)
{
b=a;
b=b.replace(*n*
,i);
document.getElementById('dply').innerHTML = document.getElementById('dply').innerHTML +
'
'+''+b+'> '+b+'>'+b+'';
}
}
}
text id=url
size=40
value=http://www.eastman.ucl.ac.uk/guide/*n*.gif
>
button onclick=curl(document.getElementById('url').value)
>
Inserting the statement b=a; allows the parameter a to always keep the initial value and the string *n* will be found and replaced with 2, 3, 4, and 5.
Question 2: Autoredirect
I am using PHP to explore the referring URL and then putting that as the location. The redirect code is as follows:
$Refer[3] = newequip.php?ClientName=$ClientNameF
;
echo '\",2500)>
;
When I load it from the page already formatted with the ClientName in the URL, it redirects perfectly. I had it formatted by replacing the spaces with %20. The server side code from this page is as follows:
location.href='\equipinfo.php?ClientName=Fox%20Theatre%20Hill&EquipName=T2',2500)>
However, when I try to do the same from the other page, which needs to be sent back with the ClientName, it is not working. The client side code from this other page is as follows:
location.href='\newequip.php?ClientName=Fox%20Theatre%20Hill',2500)>
Why does it work for one page but not for the other?
A: To make it work in both server and client side, edit the statement location .href='\newequip.php?ClientName=Fox%20Theatre%20Hill'
The backslash n (\n) makes a new line in JavaScript. If you're using this on a web server, use a forward slash instead.
Question 3: Selectbox onchange Disable Other Selectbox
I have two select boxes, but I only want the user to be able to select one of them. Both boxes are dynamic and populate data from recordsets.
Both boxes should be initially enabled. Once the user makes a selection in one of the boxes, the other should become disabled. If the user changes his mind and wants to select the other box, he should be able to select the first option (Option 0) in the box to re-enable the other box.
The following is a sample code for select boxes to start with:
How do I write a code that will allow the user to select only one box?
A: This can probably be done in a more compact bit of code, but the following may be easier to understand and quicker than waiting for a difficult-to-read function.
function chgSelect(which) {
if (which == 'County') {
if (document.getElementById('lstCounty').selectedIndex == 0) //Unlock lstCity
document.getElementById('lstCity').disabled = false;
else // lock city
document.getElementById('lstCity').disabled = true;
}
else {
if (document.getElementById('lstCity').selectedIndex == 0) //Unlock lstCounty
document.getElementById('lstCounty').disabled = false;
else // lock lstCounty
document.getElementById('lstCounty').disabled = true;
}
}
Question 4: Dynamic URL Links
I have a JavaScript loop that gets a user’s settings, from which I would like to dynamically create the user’s html links on a web page. For example, the user selects certain companies. I will then create links to the companies he selected. How do I dynamically generate html links for a list of 5 to 10 items?
A: Two of the many ways to dynamically generate html links are the following:
CODE
document.write('something.html>link');
orCODE
document.getElementById('linkContainer').innerHTML = 'something.html>link';
Question 5: Can't Find Error in Simple JavaScript
When I have the following JavaScript in my file and try to execute a function defined after it, the function is never executed. When I remove this piece, it works fine.
function findOffset(alphabet, ch)
{
var findOffset = alphabet.indexOf(ch) - 1
If (findOffset == -1) {
return -5
} else {
return findOffset
}
}
The part that gives me trouble is the If … Else statement. I have included the rest of the code to put it into context.
Is there something wrong with the above code?
A: Change the capital I in If to a lowercase i and rename the variable (it should not have the same name as the function).
Your logic has a flaw in it, too. Because you subtract 1 from the index of a character, you could get a value of -2, if the character you're checking for is not in the string called alphabet.
Putting some semicolon terminators in wouldn't go amiss either.
Question 6: String Split
I am using split() function on a string like this:
var words = s.value.split(
);
but the above statement only splits on a blank space. I also want to split on :
and -
.
The following statement didn’t work either:CODE
var words = s.value.split( |:|-
);
How do I write the