SlideShare a Scribd company logo
JavaScript
“Break, Type conversion, RegEx"
Shivam Gupta ( Full Stack Web Developer )
+91-9711626192
Overview
 JS Break
 Type Conversion
 RegEx.
JS Break Statement
 The break statement terminates the current loop, switch, or label statement and
transfers program control to the statement following the terminated statement.
 The break statement "jumps out" of a loop.
 The break statement used to "jump out" of a switch() statement.
 The break statement breaks the loop and continues executing the code after the
loop
 Syntax
break [label];
*label Optional.
Break Statement Example
 The break statement with loop.
 Example
for (i = 0; i < 10; i++) {
if (i === 3) { break; }
text += "The number is " + i + "<br>";
}
 The break statement with switch
var Animal = 'Giraffe';
switch (Animal) {
case 'Cow':
case 'Giraffe':
case 'Dog':
case 'Pig':
console.log('This animal will go on Noah's Ark.');
break;
case 'Dinosaur':
default:
console.log('This animal will not.');
}
Type Conversion
 Type conversion is converting one type of data to another type.
 JavaScript variables can be converted to a new variable and another data type:
 By the use of a JavaScript function
 Automatically by JavaScript itself
 Number() converts to a Number, String() converts to a String, Boolean() converts to
a Boolean.
 Example:
 Converting Strings to Numbers: Number("3.14")
 Converting Booleans to Strings: String(false)
 Numbers to Strings: String(123)
RegEx
 Regular expressions are used to perform pattern-matching and "search-and-
replace" functions on text.
 In JavaScript, regular expressions are also objects.
 Regex syntax
 /pattern/modifiers;
 Creating a regular expression
 var re = /pattern/modifiers ; or var re = new RegExp(”pattern”, ”modifiers”)
 Modifiers
 i, g, m
 Regex Object Methods
 exec, test, match, search, replace, split
Regex
 RegEx Pattern
 A regular expression pattern is composed of simple characters, such as /abc/, or a
combination of simple and special characters, such as /ab*c/ or /sss(d+).d*/.
 Special characters in regular expressions.
 /, ^, $, *, +, ., ?, w, [], n, (x), (x|y)
 Example:
 Executes a search:
 var myRe = /d(b+)d/g;
var myArray = myRe.exec("cdbbdbsbz"); // returns an array
 Search and Replace:
 var re = /(w+)s(w+)/;
var str = "John Smith";
var newstr = str.replace(re, "$2, $1");
console.log(newstr);
Thank you

More Related Content

What's hot (20)

PDF
JavaScript Looping Statements
Janssen Harvey Insigne
 
PPTX
Javascript conditional statements 1
Jesus Obenita Jr.
 
PDF
Vbs
santosh_axle
 
PPTX
Jslint 參數設定
Kingsley Zheng
 
PPTX
Loops in java script
Ravi Bhadauria
 
PPTX
VB Script
Satish Sukumaran
 
PPTX
Namespaces
zindadili
 
PDF
Understanding Javascript Engine to Code Better
Ihsan Fauzi Rahman
 
PPT
CSIS 138 JavaScript Class2
Teresa Pelkie
 
PPTX
Final project powerpoint template (fndprg) (1)
heoff
 
PPTX
JavaScript Loop: Optimization of Weak Typing
Janlay Wu
 
ODP
HailDB: A NoSQL API Direct to InnoDB
stewartsmith
 
PDF
Analyzing Firebird 3.0
Ekaterina Milovidova
 
PPTX
Loops in R
Chris Orwa
 
PDF
Analysis of the Trans-Proteomic Pipeline (TPP) project
PVS-Studio
 
PDF
Practical TypeScript
ldaws
 
PDF
Vb script tutorial for qtp[1]
srikanthbkm
 
PPTX
Javascript Function
xxbeta
 
PPT
Krazykoder struts2 ognl
Krazy Koder
 
PPTX
Python Training in Bangalore | Python Introduction Session | Learnbay
Learnbayin
 
JavaScript Looping Statements
Janssen Harvey Insigne
 
Javascript conditional statements 1
Jesus Obenita Jr.
 
Jslint 參數設定
Kingsley Zheng
 
Loops in java script
Ravi Bhadauria
 
VB Script
Satish Sukumaran
 
Namespaces
zindadili
 
Understanding Javascript Engine to Code Better
Ihsan Fauzi Rahman
 
CSIS 138 JavaScript Class2
Teresa Pelkie
 
Final project powerpoint template (fndprg) (1)
heoff
 
JavaScript Loop: Optimization of Weak Typing
Janlay Wu
 
HailDB: A NoSQL API Direct to InnoDB
stewartsmith
 
Analyzing Firebird 3.0
Ekaterina Milovidova
 
Loops in R
Chris Orwa
 
Analysis of the Trans-Proteomic Pipeline (TPP) project
PVS-Studio
 
Practical TypeScript
ldaws
 
Vb script tutorial for qtp[1]
srikanthbkm
 
Javascript Function
xxbeta
 
Krazykoder struts2 ognl
Krazy Koder
 
Python Training in Bangalore | Python Introduction Session | Learnbay
Learnbayin
 

Similar to Javascript - Break statement, type conversion, regular expression (20)

PPT
Javascript
Sunil Thakur
 
PDF
javascript teach
guest3732fa
 
PDF
JSBootcamp_White
guest3732fa
 
PDF
JavaScript for beginners
Shahrukh Ali Khan
 
PPTX
Introduction to Client-Side Javascript
Julie Iskander
 
PPTX
JavaScript.pptx
Govardhan Bhavani
 
PPTX
JavaScript.pptx
KennyPratheepKumar
 
PDF
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
Bryan Alejos
 
PPTX
Ch08 - Manipulating Data in Strings and Arrays
dcomfort6819
 
PPTX
JavaScript 101
Mindy McAdams
 
PPTX
An Introduction to JavaScript
tonyh1
 
PPT
9781305078444 ppt ch08
Terry Yoast
 
PDF
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
PPTX
Class[2][29th may] [javascript]
Saajid Akram
 
PDF
A Re-Introduction to JavaScript
Simon Willison
 
PDF
JavaScript introduction 1 ( Variables And Values )
Victor Verhaagen
 
PDF
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
PPTX
An introduction to javascript
tonyh1
 
PPTX
JavaScript 1 for high school
jekkilekki
 
PPTX
Cordova training : Day 3 - Introduction to Javascript
Binu Paul
 
Javascript
Sunil Thakur
 
javascript teach
guest3732fa
 
JSBootcamp_White
guest3732fa
 
JavaScript for beginners
Shahrukh Ali Khan
 
Introduction to Client-Side Javascript
Julie Iskander
 
JavaScript.pptx
Govardhan Bhavani
 
JavaScript.pptx
KennyPratheepKumar
 
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
Bryan Alejos
 
Ch08 - Manipulating Data in Strings and Arrays
dcomfort6819
 
JavaScript 101
Mindy McAdams
 
An Introduction to JavaScript
tonyh1
 
9781305078444 ppt ch08
Terry Yoast
 
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
Class[2][29th may] [javascript]
Saajid Akram
 
A Re-Introduction to JavaScript
Simon Willison
 
JavaScript introduction 1 ( Variables And Values )
Victor Verhaagen
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
An introduction to javascript
tonyh1
 
JavaScript 1 for high school
jekkilekki
 
Cordova training : Day 3 - Introduction to Javascript
Binu Paul
 
Ad

Recently uploaded (20)

PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Digital Circuits, important subject in CS
contactparinay1
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Ad

Javascript - Break statement, type conversion, regular expression

  • 1. JavaScript “Break, Type conversion, RegEx" Shivam Gupta ( Full Stack Web Developer ) +91-9711626192
  • 2. Overview  JS Break  Type Conversion  RegEx.
  • 3. JS Break Statement  The break statement terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.  The break statement "jumps out" of a loop.  The break statement used to "jump out" of a switch() statement.  The break statement breaks the loop and continues executing the code after the loop  Syntax break [label]; *label Optional.
  • 4. Break Statement Example  The break statement with loop.  Example for (i = 0; i < 10; i++) { if (i === 3) { break; } text += "The number is " + i + "<br>"; }  The break statement with switch var Animal = 'Giraffe'; switch (Animal) { case 'Cow': case 'Giraffe': case 'Dog': case 'Pig': console.log('This animal will go on Noah's Ark.'); break; case 'Dinosaur': default: console.log('This animal will not.'); }
  • 5. Type Conversion  Type conversion is converting one type of data to another type.  JavaScript variables can be converted to a new variable and another data type:  By the use of a JavaScript function  Automatically by JavaScript itself  Number() converts to a Number, String() converts to a String, Boolean() converts to a Boolean.  Example:  Converting Strings to Numbers: Number("3.14")  Converting Booleans to Strings: String(false)  Numbers to Strings: String(123)
  • 6. RegEx  Regular expressions are used to perform pattern-matching and "search-and- replace" functions on text.  In JavaScript, regular expressions are also objects.  Regex syntax  /pattern/modifiers;  Creating a regular expression  var re = /pattern/modifiers ; or var re = new RegExp(”pattern”, ”modifiers”)  Modifiers  i, g, m  Regex Object Methods  exec, test, match, search, replace, split
  • 7. Regex  RegEx Pattern  A regular expression pattern is composed of simple characters, such as /abc/, or a combination of simple and special characters, such as /ab*c/ or /sss(d+).d*/.  Special characters in regular expressions.  /, ^, $, *, +, ., ?, w, [], n, (x), (x|y)  Example:  Executes a search:  var myRe = /d(b+)d/g; var myArray = myRe.exec("cdbbdbsbz"); // returns an array  Search and Replace:  var re = /(w+)s(w+)/; var str = "John Smith"; var newstr = str.replace(re, "$2, $1"); console.log(newstr);