SlideShare a Scribd company logo
Javascript Quiz
Technical questions to ask when recruiting developers.

Alberto Naranjo
Jan. 2014
OOP
What’s prototyping?
Javascript does’nt use classical ‘inheritance’ model. It uses
prototypal inheritance. We will want to declare methods on the
prototype class, not in the constructor, mainly because when the
use new the object would create each time a new copy of the
methods instead of using the common one from the prototype.
//Guitar function constructor
function Guitar(color, strings) {
this.color = color;
this.strings = strings;
}
//Guitar prototype method
Guitar.prototype.play = function(chord){
return chord;
}
var myguitar = new Guitar(‘blue’,[‘A’,’F’,’G’]);
--------Guitar.prototype = {
play : function(chord){ return chord; },
getColor : function(){ return this.color; }
};
How to create objects with properties?
Also add a function as a property.

var man = new Object();
man.name = ‘Alberto Naranjo’;
man.getName = function(){ return this.name; }
console.log(man.getName()); //logs Alberto Naranjo
Implement dot and literals object
notation. What’s the difference?

There is no practical difference.
var man = new Object();
man.name = “Albert”; // man[‘name’] = “Albert”;
man.age = 29; // man[‘age’] = 29;
---------var man = { ‘name’ : “Andrew”, ‘age’ : 27 };
Inheritance, how can you do
it in JS? :)
Simple guide to inheritance:
http://phrogz.net/JS/classes/OOPinJS2.html
Cat.prototype = new Mammal(); //Inheritance occurs
Cat.prototype.constructor = Cat; //Override new constructor
function Cat(name){ this.name=name; } //New constructor
//We can override any method, and inherit old methods.
General Syntax
What’s event bubbling and event
propagation. How to stop propagation?
Event bubbling describe the behavior of events in child and
parents nodes in the Document Object Model. The child
pass their events to their parents nodes. The main benefit of
this behavior is the speed because the code has to traverse
the DOM tree only once. And simplicity because you only
need one event listener for all children nodes. For example, a
click event listener in page’s body element, will trigger on
any click of the inner components. Event capturing also
called bubble down. Where outer elements events trigger
before inner (parents before children).
event.stopPropagation();
event.cancelBubble = true; //for IE<9
Implement dynamic function
calling using dynamic parameters.

var myDynamicFunc = (function(text){ alert(text); })(‘Hello!’);
What’s a closure? Implement
an example.
A closure is an inner function with 3 scopes: local
variables, outer variables and global variables.
function showName (firstName, lastName) {
var nameIntro = "Your name is ";
//this inner function has access to the outer function's variables, including params
function makeFullName () {
return nameIntro + firstName + " " + lastName;
}
return makeFullName ();
}
showName ("Michael", "Jackson"); // Your name is Michael Jackson
Explain differences between ==
and ===. Implement an example.
Briefly == will only check for the value, and === (strict
equality) will check also for the type/object without
type conversion. When comparing objects === will
return false if they are not the same pointer/reference
to the same object even if the have the same value.
object1 = new Number(‘10’);
object2 = new Number(‘10’);
object3 = object2;
console.log(object1 === object2); //false
console.log(object2 === object3); //true
Global vs local variable
definition. Implement both.
Related to the scope, a global variable has no scope
and it’s available on any place of the code. Good
programmer should avoid it in all situations. A local
variable has a local scope, inside a object, block or
structure.
globalvar=true;
var localvar=true;
How the this keyword works?

In Javascript the this keyword usually references the
object who owns the method. But depending on the
scope. Sometimes you use this in reference to the
Window object. When working with event handlers
this references the object who created the event.
How do you do error
handling in JS? Implement.
You can use the structure try-catch-finally to manage
the error handling.
try {
//do something.
} catch(e) {
console.log(e.message);
document.write ("Error Message: " + e.message);
document.write ("<br />");
document.write ("Error Code: ");
document.write (e.number & 0xFFFF);
document.write ("<br />");
document.write ("Error Name: " + e.name);
} finally {
//do something always.
}
Enumerate all Javascript
types.
1. Number
2. Boolean
3. String
4. Object
5. function
6. null
7. undefined
How timers work? What you
should be aware of?
They run in a single thread so there would be events
in queue.
setTimeout(function, miliseconds);
------var id = setInterval(function, miliseconds);
clearInterval(id);
How do you read or modify any
property from a DOM element?

var myProperty = document.getElementById(‘id’).property;
document.getElementById(‘id’).value = ‘Hello!’;
Arrays
Implement a simple array
with 3 elements

var myArray = new Array(‘a’,’b’,’c’);
Implement an associative
array.
I will use a literal object notation to create one.

var myArray={key1: 'value1', key2:'value2' };
alert(myArray[‘key1’]); // Also myArray.key1
There is such for-each block
in Javascript?
There is one, but it’s not fully supported. You can use
also for-in structure.
a.forEach( function(entry) { console.log(entry); });
------var key;
for (key in a) {
console.log(a.key);
}
Suggest more
questions ;)
Ad

More Related Content

What's hot (20)

Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
Pragya Rastogi
 
Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy Testing
Andres Almiray
 
Headless Js Testing
Headless Js TestingHeadless Js Testing
Headless Js Testing
Brian Moschel
 
Svcc Java2D And Groovy
Svcc Java2D And GroovySvcc Java2D And Groovy
Svcc Java2D And Groovy
Andres Almiray
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
Anjan Banda
 
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesAnalyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
PVS-Studio
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
Mats Bryntse
 
Introduction to Grails Framework
Introduction to Grails FrameworkIntroduction to Grails Framework
Introduction to Grails Framework
PT.JUG
 
CodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderCodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilder
Andres Almiray
 
Informatics Practice Practical for 12th class
Informatics Practice Practical for 12th classInformatics Practice Practical for 12th class
Informatics Practice Practical for 12th class
phultoosks876
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
ygv2000
 
ES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD CalculatorES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD Calculator
David Rodenas
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
NexThoughts Technologies
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
Ori Calvo
 
One Year of Clean Architecture - The Good, The Bad and The Bob
One Year of Clean Architecture - The Good, The Bad and The BobOne Year of Clean Architecture - The Good, The Bad and The Bob
One Year of Clean Architecture - The Good, The Bad and The Bob
OCTO Technology
 
Javantura v2 - Making Java web-apps Groovy - Franjo Žilić
Javantura v2 - Making Java web-apps Groovy - Franjo ŽilićJavantura v2 - Making Java web-apps Groovy - Franjo Žilić
Javantura v2 - Making Java web-apps Groovy - Franjo Žilić
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
Mohammed Sazid Al Rashid
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
Azul Systems Inc.
 
Qtp not just for gui anymore
Qtp   not just for gui anymoreQtp   not just for gui anymore
Qtp not just for gui anymore
Pragya Rastogi
 
Svcc Java2D And Groovy
Svcc Java2D And GroovySvcc Java2D And Groovy
Svcc Java2D And Groovy
Andres Almiray
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
Anjan Banda
 
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" DependenciesAnalyzing FreeCAD's Source Code and Its "Sick" Dependencies
Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
PVS-Studio
 
Introduction to Grails Framework
Introduction to Grails FrameworkIntroduction to Grails Framework
Introduction to Grails Framework
PT.JUG
 
CodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderCodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilder
Andres Almiray
 
Informatics Practice Practical for 12th class
Informatics Practice Practical for 12th classInformatics Practice Practical for 12th class
Informatics Practice Practical for 12th class
phultoosks876
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
ygv2000
 
ES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD CalculatorES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD Calculator
David Rodenas
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
Ori Calvo
 
One Year of Clean Architecture - The Good, The Bad and The Bob
One Year of Clean Architecture - The Good, The Bad and The BobOne Year of Clean Architecture - The Good, The Bad and The Bob
One Year of Clean Architecture - The Good, The Bad and The Bob
OCTO Technology
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 

Viewers also liked (8)

Bit%20 ch02
Bit%20 ch02Bit%20 ch02
Bit%20 ch02
Kodchawan Yookong
 
Javascript quiz
Javascript quizJavascript quiz
Javascript quiz
DM's College, Assagao Goa
 
Chapter 4 Programs and Apps
Chapter 4 Programs and AppsChapter 4 Programs and Apps
Chapter 4 Programs and Apps
xtin101
 
21 Essential JavaScript Interview Questions
21 Essential JavaScript Interview Questions21 Essential JavaScript Interview Questions
21 Essential JavaScript Interview Questions
Arc & Codementor
 
Chapter 3 Computers and Mobile Devices
Chapter 3 Computers and Mobile DevicesChapter 3 Computers and Mobile Devices
Chapter 3 Computers and Mobile Devices
xtin101
 
Mcq of e comm
Mcq of e commMcq of e comm
Mcq of e comm
Suman Madan
 
Html interview-questions-and-answers
Html interview-questions-and-answersHtml interview-questions-and-answers
Html interview-questions-and-answers
MohitKumar1985
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
Volker Hirsch
 
Chapter 4 Programs and Apps
Chapter 4 Programs and AppsChapter 4 Programs and Apps
Chapter 4 Programs and Apps
xtin101
 
21 Essential JavaScript Interview Questions
21 Essential JavaScript Interview Questions21 Essential JavaScript Interview Questions
21 Essential JavaScript Interview Questions
Arc & Codementor
 
Chapter 3 Computers and Mobile Devices
Chapter 3 Computers and Mobile DevicesChapter 3 Computers and Mobile Devices
Chapter 3 Computers and Mobile Devices
xtin101
 
Html interview-questions-and-answers
Html interview-questions-and-answersHtml interview-questions-and-answers
Html interview-questions-and-answers
MohitKumar1985
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
Volker Hirsch
 
Ad

Similar to Javascript quiz. Questions to ask when recruiting developers. (20)

Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Subramanyan Murali
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
Hoat Le
 
Writing JavaScript that doesn't suck
Writing JavaScript that doesn't suckWriting JavaScript that doesn't suck
Writing JavaScript that doesn't suck
Ross Bruniges
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
Rodica Dada
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
Núcleo de Electrónica e Informática da Universidade do Algarve
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Zohar Arad
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Nascenia IT
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
Christian Heilmann
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_ods
 
Java script object model
Java script object modelJava script object model
Java script object model
James Hsieh
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
Thomas Kjeldahl Nilsson
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
Piyush Katariya
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
jeresig
 
Orlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't SuckOrlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't Suck
erockendude
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Naresha K
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Abimbola Idowu
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
David Atchley
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
Hoat Le
 
Writing JavaScript that doesn't suck
Writing JavaScript that doesn't suckWriting JavaScript that doesn't suck
Writing JavaScript that doesn't suck
Ross Bruniges
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Zohar Arad
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Nascenia IT
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_ods
 
Java script object model
Java script object modelJava script object model
Java script object model
James Hsieh
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
Piyush Katariya
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
jeresig
 
Orlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't SuckOrlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't Suck
erockendude
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Naresha K
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Abimbola Idowu
 
Ad

Recently uploaded (20)

Network Detection and Response (NDR): The Future of Intelligent Cybersecurity
Network Detection and Response (NDR): The Future of Intelligent CybersecurityNetwork Detection and Response (NDR): The Future of Intelligent Cybersecurity
Network Detection and Response (NDR): The Future of Intelligent Cybersecurity
GauriKale30
 
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
ThiNgc22
 
Best Ever Platform To Buy Verified Wise Accounts In 2025.pdf
Best Ever Platform To Buy Verified Wise Accounts In 2025.pdfBest Ever Platform To Buy Verified Wise Accounts In 2025.pdf
Best Ever Platform To Buy Verified Wise Accounts In 2025.pdf
Topvasmm
 
Disinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key FindingsDisinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key Findings
MariumAbdulhussein
 
intra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.pptintra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.ppt
NTTDATA INTRAMART
 
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
TheoRuby
 
From Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The ChhapaiFrom Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The Chhapai
The Chhapai
 
Brandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled MusicianBrandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled Musician
Brandon Flatley
 
Kunal Bansal_ Building More Than Infrastructure in Chandigarh.pdf
Kunal Bansal_ Building More Than Infrastructure in Chandigarh.pdfKunal Bansal_ Building More Than Infrastructure in Chandigarh.pdf
Kunal Bansal_ Building More Than Infrastructure in Chandigarh.pdf
Kunal Bansal Chandigarh
 
Kiran Flemish - A Dynamic Musician
Kiran  Flemish  -  A   Dynamic  MusicianKiran  Flemish  -  A   Dynamic  Musician
Kiran Flemish - A Dynamic Musician
Kiran Flemish
 
Level Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up SuccessLevel Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up Success
Best Virtual Specialist
 
TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...
TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...
TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...
Kirill Klip
 
Top 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job ApplicationTop 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job Application
Red Tape Busters
 
Track Social Media Activity Using Web Scraping
Track Social Media Activity Using Web ScrapingTrack Social Media Activity Using Web Scraping
Track Social Media Activity Using Web Scraping
Web Screen Scraping
 
Comments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Comments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdfComments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Comments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Brij Consulting, LLC
 
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdfAccounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
Harnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail StrategyHarnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail Strategy
RUPAL AGARWAL
 
Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)
GeorgeButtler
 
Treis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IVTreis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IV
aparicioregina7
 
Google Ads vs. Meta Ads: The Best Platform for Real Estate Marketing
Google Ads vs. Meta Ads: The Best Platform for Real Estate MarketingGoogle Ads vs. Meta Ads: The Best Platform for Real Estate Marketing
Google Ads vs. Meta Ads: The Best Platform for Real Estate Marketing
Woospers
 
Network Detection and Response (NDR): The Future of Intelligent Cybersecurity
Network Detection and Response (NDR): The Future of Intelligent CybersecurityNetwork Detection and Response (NDR): The Future of Intelligent Cybersecurity
Network Detection and Response (NDR): The Future of Intelligent Cybersecurity
GauriKale30
 
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
ThiNgc22
 
Best Ever Platform To Buy Verified Wise Accounts In 2025.pdf
Best Ever Platform To Buy Verified Wise Accounts In 2025.pdfBest Ever Platform To Buy Verified Wise Accounts In 2025.pdf
Best Ever Platform To Buy Verified Wise Accounts In 2025.pdf
Topvasmm
 
Disinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key FindingsDisinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key Findings
MariumAbdulhussein
 
intra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.pptintra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.ppt
NTTDATA INTRAMART
 
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
TheoRuby
 
From Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The ChhapaiFrom Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The Chhapai
The Chhapai
 
Brandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled MusicianBrandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled Musician
Brandon Flatley
 
Kunal Bansal_ Building More Than Infrastructure in Chandigarh.pdf
Kunal Bansal_ Building More Than Infrastructure in Chandigarh.pdfKunal Bansal_ Building More Than Infrastructure in Chandigarh.pdf
Kunal Bansal_ Building More Than Infrastructure in Chandigarh.pdf
Kunal Bansal Chandigarh
 
Kiran Flemish - A Dynamic Musician
Kiran  Flemish  -  A   Dynamic  MusicianKiran  Flemish  -  A   Dynamic  Musician
Kiran Flemish - A Dynamic Musician
Kiran Flemish
 
Level Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up SuccessLevel Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up Success
Best Virtual Specialist
 
TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...
TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...
TNR Gold Investor Elevator Pitch - Building The Green Energy Metals Royalty a...
Kirill Klip
 
Top 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job ApplicationTop 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job Application
Red Tape Busters
 
Track Social Media Activity Using Web Scraping
Track Social Media Activity Using Web ScrapingTrack Social Media Activity Using Web Scraping
Track Social Media Activity Using Web Scraping
Web Screen Scraping
 
Comments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Comments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdfComments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Comments on Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Brij Consulting, LLC
 
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdfAccounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
Harnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail StrategyHarnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail Strategy
RUPAL AGARWAL
 
Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)Smart Home Market Size, Growth and Report (2025-2034)
Smart Home Market Size, Growth and Report (2025-2034)
GeorgeButtler
 
Treis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IVTreis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IV
aparicioregina7
 
Google Ads vs. Meta Ads: The Best Platform for Real Estate Marketing
Google Ads vs. Meta Ads: The Best Platform for Real Estate MarketingGoogle Ads vs. Meta Ads: The Best Platform for Real Estate Marketing
Google Ads vs. Meta Ads: The Best Platform for Real Estate Marketing
Woospers
 

Javascript quiz. Questions to ask when recruiting developers.

  • 1. Javascript Quiz Technical questions to ask when recruiting developers. Alberto Naranjo Jan. 2014
  • 2. OOP
  • 3. What’s prototyping? Javascript does’nt use classical ‘inheritance’ model. It uses prototypal inheritance. We will want to declare methods on the prototype class, not in the constructor, mainly because when the use new the object would create each time a new copy of the methods instead of using the common one from the prototype. //Guitar function constructor function Guitar(color, strings) { this.color = color; this.strings = strings; } //Guitar prototype method Guitar.prototype.play = function(chord){ return chord; } var myguitar = new Guitar(‘blue’,[‘A’,’F’,’G’]); --------Guitar.prototype = { play : function(chord){ return chord; }, getColor : function(){ return this.color; } };
  • 4. How to create objects with properties? Also add a function as a property. var man = new Object(); man.name = ‘Alberto Naranjo’; man.getName = function(){ return this.name; } console.log(man.getName()); //logs Alberto Naranjo
  • 5. Implement dot and literals object notation. What’s the difference? There is no practical difference. var man = new Object(); man.name = “Albert”; // man[‘name’] = “Albert”; man.age = 29; // man[‘age’] = 29; ---------var man = { ‘name’ : “Andrew”, ‘age’ : 27 };
  • 6. Inheritance, how can you do it in JS? :) Simple guide to inheritance: http://phrogz.net/JS/classes/OOPinJS2.html Cat.prototype = new Mammal(); //Inheritance occurs Cat.prototype.constructor = Cat; //Override new constructor function Cat(name){ this.name=name; } //New constructor //We can override any method, and inherit old methods.
  • 8. What’s event bubbling and event propagation. How to stop propagation? Event bubbling describe the behavior of events in child and parents nodes in the Document Object Model. The child pass their events to their parents nodes. The main benefit of this behavior is the speed because the code has to traverse the DOM tree only once. And simplicity because you only need one event listener for all children nodes. For example, a click event listener in page’s body element, will trigger on any click of the inner components. Event capturing also called bubble down. Where outer elements events trigger before inner (parents before children). event.stopPropagation(); event.cancelBubble = true; //for IE<9
  • 9. Implement dynamic function calling using dynamic parameters. var myDynamicFunc = (function(text){ alert(text); })(‘Hello!’);
  • 10. What’s a closure? Implement an example. A closure is an inner function with 3 scopes: local variables, outer variables and global variables. function showName (firstName, lastName) { var nameIntro = "Your name is "; //this inner function has access to the outer function's variables, including params function makeFullName () { return nameIntro + firstName + " " + lastName; } return makeFullName (); } showName ("Michael", "Jackson"); // Your name is Michael Jackson
  • 11. Explain differences between == and ===. Implement an example. Briefly == will only check for the value, and === (strict equality) will check also for the type/object without type conversion. When comparing objects === will return false if they are not the same pointer/reference to the same object even if the have the same value. object1 = new Number(‘10’); object2 = new Number(‘10’); object3 = object2; console.log(object1 === object2); //false console.log(object2 === object3); //true
  • 12. Global vs local variable definition. Implement both. Related to the scope, a global variable has no scope and it’s available on any place of the code. Good programmer should avoid it in all situations. A local variable has a local scope, inside a object, block or structure. globalvar=true; var localvar=true;
  • 13. How the this keyword works? In Javascript the this keyword usually references the object who owns the method. But depending on the scope. Sometimes you use this in reference to the Window object. When working with event handlers this references the object who created the event.
  • 14. How do you do error handling in JS? Implement. You can use the structure try-catch-finally to manage the error handling. try { //do something. } catch(e) { console.log(e.message); document.write ("Error Message: " + e.message); document.write ("<br />"); document.write ("Error Code: "); document.write (e.number & 0xFFFF); document.write ("<br />"); document.write ("Error Name: " + e.name); } finally { //do something always. }
  • 15. Enumerate all Javascript types. 1. Number 2. Boolean 3. String 4. Object 5. function 6. null 7. undefined
  • 16. How timers work? What you should be aware of? They run in a single thread so there would be events in queue. setTimeout(function, miliseconds); ------var id = setInterval(function, miliseconds); clearInterval(id);
  • 17. How do you read or modify any property from a DOM element? var myProperty = document.getElementById(‘id’).property; document.getElementById(‘id’).value = ‘Hello!’;
  • 19. Implement a simple array with 3 elements var myArray = new Array(‘a’,’b’,’c’);
  • 20. Implement an associative array. I will use a literal object notation to create one. var myArray={key1: 'value1', key2:'value2' }; alert(myArray[‘key1’]); // Also myArray.key1
  • 21. There is such for-each block in Javascript? There is one, but it’s not fully supported. You can use also for-in structure. a.forEach( function(entry) { console.log(entry); }); ------var key; for (key in a) { console.log(a.key); }