SlideShare une entreprise Scribd logo
1  sur  10
JavaScript
Iterations
Charles Russell
Bennu Bird Media
Changes in Direction
●
In the previous video we allowed our program to
change flow to one of many different program
blocks
●
But that is not the only direction change we may
want. It is often desireable to repeatedly execute
the same block
●
Looking for some value in a list
●
Sending a group email
●
In other words we want to loop
The While loop
●
At the top of the loop the condition is checked
●
If the condition is met then execute code block
●
Loop will continue until condition not met.
while (conditional expression) {
//Do some stuff
}
●
Be sure that eventually the condition will not be
met otherwise you get an infinite loop;
The Do loop
●
At the bottom of the loop condition is checked
●
Assures the code block will be executed at least
once
●
Loop continues until condition false
do {
//code to execute goes here
} while (conditional expression);
Basic For loop
●
Executes the loop a number of times
●
Has three statements
●
First excutes before the loop is executed
– Usually used for initialization
●
Second conditional expression
– Code executes if true
●
Third
– Executes after the code block before the next
iteration
Basic For Syntax
for (init ; conditional exp; prepForNext) {
//do some stuff
}
For looping through
properties
●
Used to examine properties of an object
●
Important to filter as all properties examined
even those inherited from parent and its
parent....
for (variable in Object) {
if ( Object.hasOwnProperty(variable) {
//code to execute
}
}
Cutting the loop
●
break
●
Halts code execution in the loop
– Stop further execution of code block and exit the
loop
●
continue
●
Halts execution of the rest of the code block
●
Continues next iteration
Summary
●
Iteration is another word for looping
●
While loops check for conditional at the top of
the loop
●
Be wary of the infinite loop
●
Do loops check conditional at bottom of the loop
●
Basic for loops allow loops to be controlled by
number of executions
●
For in loops will check properties of Objects and
Arrays
●
Be sure to use hasOwnProperty method.
Next: Live Code

Contenu connexe

Tendances

Presenter kn
Presenter knPresenter kn
Presenter knogomr
 
An introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScriptAn introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScriptTO THE NEW | Technology
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While LoopAbhishek Choksi
 
A tale of two(many) proxies
A tale of two(many) proxiesA tale of two(many) proxies
A tale of two(many) proxiesMohan Dutt
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overviewAyman Mahfouz
 
Exploring reactive programming with Java
Exploring reactive programming with JavaExploring reactive programming with Java
Exploring reactive programming with JavaMiro Cupak
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGlobalLogic Ukraine
 
Loop control structure
Loop control structureLoop control structure
Loop control structurenarmadhakin
 
Best practices for unit testing RxJava
Best practices for unit testing RxJavaBest practices for unit testing RxJava
Best practices for unit testing RxJavaSimon Percic
 
Practical introduction to the actor model
Practical introduction to the actor modelPractical introduction to the actor model
Practical introduction to the actor modelGeorgios Gousios
 
Reactive programming in Java
Reactive programming in JavaReactive programming in Java
Reactive programming in JavaMiro Cupak
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion StatementsHuda Alameen
 
Dangers of parallel streams
Dangers of parallel streamsDangers of parallel streams
Dangers of parallel streamsLukáš Křečan
 

Tendances (20)

Presenter kn
Presenter knPresenter kn
Presenter kn
 
An introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScriptAn introduction to Object Oriented JavaScript
An introduction to Object Oriented JavaScript
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
JAVA Threads explained
JAVA Threads explained JAVA Threads explained
JAVA Threads explained
 
A tale of two(many) proxies
A tale of two(many) proxiesA tale of two(many) proxies
A tale of two(many) proxies
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overview
 
Exploring reactive programming with Java
Exploring reactive programming with JavaExploring reactive programming with Java
Exploring reactive programming with Java
 
Java Control Statements
Java Control StatementsJava Control Statements
Java Control Statements
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii Shapoval
 
JS knowing-nuances
JS knowing-nuancesJS knowing-nuances
JS knowing-nuances
 
Loop control structure
Loop control structureLoop control structure
Loop control structure
 
Best practices for unit testing RxJava
Best practices for unit testing RxJavaBest practices for unit testing RxJava
Best practices for unit testing RxJava
 
Practical introduction to the actor model
Practical introduction to the actor modelPractical introduction to the actor model
Practical introduction to the actor model
 
For
ForFor
For
 
Reactive programming in Java
Reactive programming in JavaReactive programming in Java
Reactive programming in Java
 
Ratpack JVM_MX Meetup February 2016
Ratpack JVM_MX Meetup February 2016Ratpack JVM_MX Meetup February 2016
Ratpack JVM_MX Meetup February 2016
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Groovy MOPping
Groovy MOPpingGroovy MOPping
Groovy MOPping
 
Dangers of parallel streams
Dangers of parallel streamsDangers of parallel streams
Dangers of parallel streams
 
Computer programming 2 Lesson 8
Computer programming 2  Lesson 8Computer programming 2  Lesson 8
Computer programming 2 Lesson 8
 

En vedette

JavaScript Tools and Implementation
JavaScript Tools and ImplementationJavaScript Tools and Implementation
JavaScript Tools and ImplementationCharles Russell
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to FunctionsCharles Russell
 
JavaScript Comments and Conditionals
JavaScript Comments and ConditionalsJavaScript Comments and Conditionals
JavaScript Comments and ConditionalsCharles Russell
 
Javascript built in String Functions
Javascript built in String FunctionsJavascript built in String Functions
Javascript built in String FunctionsAvanitrambadiya
 
Boom Boom! Revolution Press Kit
Boom Boom! Revolution Press KitBoom Boom! Revolution Press Kit
Boom Boom! Revolution Press KitBoom Boom! Cards
 
Designing Websites in Photoshop
Designing Websites in PhotoshopDesigning Websites in Photoshop
Designing Websites in PhotoshopBrunner
 
Creating simple web design in photoshop
Creating simple web design in photoshopCreating simple web design in photoshop
Creating simple web design in photoshoplillianabe
 
Javascript - Break statement, type conversion, regular expression
Javascript - Break statement, type conversion, regular expressionJavascript - Break statement, type conversion, regular expression
Javascript - Break statement, type conversion, regular expressionShivam gupta
 

En vedette (15)

JavaScript Tools and Implementation
JavaScript Tools and ImplementationJavaScript Tools and Implementation
JavaScript Tools and Implementation
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to Functions
 
JavaScript Comments and Conditionals
JavaScript Comments and ConditionalsJavaScript Comments and Conditionals
JavaScript Comments and Conditionals
 
Javascript built in String Functions
Javascript built in String FunctionsJavascript built in String Functions
Javascript built in String Functions
 
Boom Boom! Revolution Press Kit
Boom Boom! Revolution Press KitBoom Boom! Revolution Press Kit
Boom Boom! Revolution Press Kit
 
Designing Websites in Photoshop
Designing Websites in PhotoshopDesigning Websites in Photoshop
Designing Websites in Photoshop
 
XML
XMLXML
XML
 
Open Source Software
Open Source SoftwareOpen Source Software
Open Source Software
 
Js objects
Js objectsJs objects
Js objects
 
JavaScript Operators
JavaScript OperatorsJavaScript Operators
JavaScript Operators
 
Creating simple web design in photoshop
Creating simple web design in photoshopCreating simple web design in photoshop
Creating simple web design in photoshop
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
 
JavaScript Variables
JavaScript VariablesJavaScript Variables
JavaScript Variables
 
Javascript - Break statement, type conversion, regular expression
Javascript - Break statement, type conversion, regular expressionJavascript - Break statement, type conversion, regular expression
Javascript - Break statement, type conversion, regular expression
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript Introduction
 

Similaire à JavaScript iteration

Similaire à JavaScript iteration (20)

Programming in python - Week 4
Programming in python  - Week 4Programming in python  - Week 4
Programming in python - Week 4
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 
C language 2
C language 2C language 2
C language 2
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Phasers to stunning
Phasers to stunningPhasers to stunning
Phasers to stunning
 
Multithreading programming in java
Multithreading programming in javaMultithreading programming in java
Multithreading programming in java
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
1660213363910.pdf
1660213363910.pdf1660213363910.pdf
1660213363910.pdf
 
Loops in C.pptx
Loops in C.pptxLoops in C.pptx
Loops in C.pptx
 
Using loops
Using loopsUsing loops
Using loops
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14
 
R loops
R   loopsR   loops
R loops
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
 

Dernier

75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptxAsmae Rabhi
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查ydyuyu
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxgalaxypingy
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsMonica Sydney
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsMonica Sydney
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoilmeghakumariji156
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.krishnachandrapal52
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Roommeghakumariji156
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样ayvbos
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样ayvbos
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolinonuriaiuzzolino1
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdfMatthew Sinclair
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 

Dernier (20)

75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolino
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 

JavaScript iteration

  • 2. Changes in Direction ● In the previous video we allowed our program to change flow to one of many different program blocks ● But that is not the only direction change we may want. It is often desireable to repeatedly execute the same block ● Looking for some value in a list ● Sending a group email ● In other words we want to loop
  • 3. The While loop ● At the top of the loop the condition is checked ● If the condition is met then execute code block ● Loop will continue until condition not met. while (conditional expression) { //Do some stuff } ● Be sure that eventually the condition will not be met otherwise you get an infinite loop;
  • 4. The Do loop ● At the bottom of the loop condition is checked ● Assures the code block will be executed at least once ● Loop continues until condition false do { //code to execute goes here } while (conditional expression);
  • 5. Basic For loop ● Executes the loop a number of times ● Has three statements ● First excutes before the loop is executed – Usually used for initialization ● Second conditional expression – Code executes if true ● Third – Executes after the code block before the next iteration
  • 6. Basic For Syntax for (init ; conditional exp; prepForNext) { //do some stuff }
  • 7. For looping through properties ● Used to examine properties of an object ● Important to filter as all properties examined even those inherited from parent and its parent.... for (variable in Object) { if ( Object.hasOwnProperty(variable) { //code to execute } }
  • 8. Cutting the loop ● break ● Halts code execution in the loop – Stop further execution of code block and exit the loop ● continue ● Halts execution of the rest of the code block ● Continues next iteration
  • 9. Summary ● Iteration is another word for looping ● While loops check for conditional at the top of the loop ● Be wary of the infinite loop ● Do loops check conditional at bottom of the loop ● Basic for loops allow loops to be controlled by number of executions ● For in loops will check properties of Objects and Arrays ● Be sure to use hasOwnProperty method.