SlideShare a Scribd company logo
1 of 16
KNOWLEDGE TRANSFER AND
SHARING
(Java script Common Mistake’s)
Syntax Error
1. Missing Semicolon (;)
println(“n Welcome 1”) ; // Missing
for(var i= 0 ;i<10;i++)
2. Missing curly braces ({}).
for(var i= 0 ;i<10;i++){ } // Missing
function test (){ } // Missing
3 . Missing Open close braces ().
function test ( param1,param2 ) // Missing
4. Missing Commas (,).
var a = “A’” ,b = “B” // Oops, missing ',' here!
c = “C”, d = “D”;
JavaScript Is
case sensitive
• JavaScript is very case sensitive.
• Example :
function test1(inputContext){
println( “n inputContext ”+InputContext);
}
inputContext is different from InputContext.
Confusion between Concatenation and
Addition
1. Println (10 +2)
Type of 2 is Number – Addition
-- result : 12
2. Println (10 + “2”)
Type of 2 is String – Concatenation
--result : 102
Confusing single and
double quotes
1. Println ('Two’);
-- result is Two
2. Println ("Two's");
-- result is Two’s
3. Println ('Two's');
-- Error
Variable
without - var
• JavaScript is very permissive.
• It will silently declare it for you globally.
• Memory Leakage.
• Significantly reduce the chance of bad
interactions with other applications libraries.
Differentiate float numbers
from integer numbers
• Example:
var myNumber = 3.5;
var myResult = 3.5 + 1.0; //We use .0 to keep the result as float
1. No difference between float and integers.
2. Don’t use decimals to “convert” numbers to
floats.
var myNumber = 3.5;
var myResult = 3.5 + 1; //Result is 4.5, as expected
Don't Use Short Hand
• Curly braces should be omitted is with one-liners.
Example:
if(someVariableExists)
x = false
anotherFunctionCall();
It means:
if(someVariableExists) {
x = false;
}
anotherFunctionCall();
Missing HasOwnProperty
for Object
• Example :
for(key in object) {
variable = object[key] ; // includes object properties
}
}
• Solution:
for(key in object) {
if(object.hasOwnProperty(key) {
...then do something...
}
}
Eval is Evil.
• Give Access to JavaScript Compiler.
• Debug message arising from Eval are
unsearchable.
• Eval (String Parameter) then ,
– Decrease Performance
– Huge Security Risk .
Undefined Property
• Example:
var object ={
key1 = {},
key2 = undefined
}
- Running loop for checking existence of an elements
typeof object [key1] = object,
typeof object [key2] = undefined
typeof object [key3] = undefined
• Solution:
key2 = null
Misuse of Closures
• Example:
function(a, b, c) {
var d = 10;
function test (a,b,c,d){
return a+b+c+d;
}}
• Solution:
function(a, b, c) {
var d = 10;
function test (){
return a+b+c+d;
}}
Conditional Statements
• Example:
1. If(var1 = var2 ) // Assignment
-- if (var 1 == var 2)
1. for(var i=0;i<10;i) // execute in infinite loop
-- for (var i=0;i<10;i++)
1. for (var i=0;i< Array.length;i++)
-- var arrLen = Array.length;
for(var 1=0;i<arrlen; i++)
Overwriting/Overloading
function
• Overloading : Declare function more than Once
with different arguments.
• No function overloading in JavaScript.
• Last compiled function definition is used.
• This behavior is different from other
Programming Language.
Example :
-function test (param1)
- function test (param1, param2)
Missing Parameter
• Forgot to update to function calls when new
parameter add in function.
• Example:
– function(param1, param2){}
– Add new parameter Param3
– function (param1,param2,param3){
param3 = param3 II Default Value
}
JavaScript Code
Quality Tools
• Firebug
• Firebug is an extremely popular and well-
regarded front-end debugging tool.
• Drosera
Drosera is an excellent debugging tool for
Safari and WebKit-based browsers.
• NitobiBug
NitobiBug is a browser-based JavaScript object
logger and inspector

More Related Content

What's hot

Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)HamletDRC
 
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...WebStackAcademy
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesAndrey Karpov
 
Pavel kravchenko obj c runtime
Pavel kravchenko obj c runtimePavel kravchenko obj c runtime
Pavel kravchenko obj c runtimeDneprCiklumEvents
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScriptSimon Willison
 
Zhongl scala summary
Zhongl scala summaryZhongl scala summary
Zhongl scala summarylunfu zhong
 
Automatically Documenting Program Changes
Automatically Documenting Program ChangesAutomatically Documenting Program Changes
Automatically Documenting Program ChangesRay Buse
 
javascript objects
javascript objectsjavascript objects
javascript objectsVijay Kalyan
 
NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#tcaesvk
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functionsVictor Verhaagen
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript Dhananjay Kumar
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScriptRasan Samarasinghe
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Abu Saleh
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 

What's hot (20)

Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
Pavel kravchenko obj c runtime
Pavel kravchenko obj c runtimePavel kravchenko obj c runtime
Pavel kravchenko obj c runtime
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Clean code
Clean codeClean code
Clean code
 
Zhongl scala summary
Zhongl scala summaryZhongl scala summary
Zhongl scala summary
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
 
Automatically Documenting Program Changes
Automatically Documenting Program ChangesAutomatically Documenting Program Changes
Automatically Documenting Program Changes
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
TDD Training
TDD TrainingTDD Training
TDD Training
 
VHDL Behavioral Description
VHDL Behavioral DescriptionVHDL Behavioral Description
VHDL Behavioral Description
 
Solid scala
Solid scalaSolid scala
Solid scala
 
block
blockblock
block
 
NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 

Similar to JavaScript Common Mistake

An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scalaXing
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java DevelopersMartin Ockajak
 
A Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalA Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalQA or the Highway
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsFITC
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Anis Bouhachem Djer
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven PractisesRobert MacLean
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javacAnna Brzezińska
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctestmitnk
 
Scala introduction
Scala introductionScala introduction
Scala introductionvito jeng
 
關於測試,我說的其實是......
關於測試,我說的其實是......關於測試,我說的其實是......
關於測試,我說的其實是......hugo lu
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almostQuinton Sheppard
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Hector Correa
 

Similar to JavaScript Common Mistake (20)

An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
A Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert FornalA Lifecycle Of Code Under Test by Robert Fornal
A Lifecycle Of Code Under Test by Robert Fornal
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
 
Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)Angularjs Test Driven Development (TDD)
Angularjs Test Driven Development (TDD)
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctest
 
Specs2
Specs2Specs2
Specs2
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
關於測試,我說的其實是......
關於測試,我說的其實是......關於測試,我說的其實是......
關於測試,我說的其實是......
 
Swift 2
Swift 2Swift 2
Swift 2
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications
 

Recently uploaded

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 

Recently uploaded (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 

JavaScript Common Mistake

  • 1. KNOWLEDGE TRANSFER AND SHARING (Java script Common Mistake’s)
  • 2. Syntax Error 1. Missing Semicolon (;) println(“n Welcome 1”) ; // Missing for(var i= 0 ;i<10;i++) 2. Missing curly braces ({}). for(var i= 0 ;i<10;i++){ } // Missing function test (){ } // Missing 3 . Missing Open close braces (). function test ( param1,param2 ) // Missing 4. Missing Commas (,). var a = “A’” ,b = “B” // Oops, missing ',' here! c = “C”, d = “D”;
  • 3. JavaScript Is case sensitive • JavaScript is very case sensitive. • Example : function test1(inputContext){ println( “n inputContext ”+InputContext); } inputContext is different from InputContext.
  • 4. Confusion between Concatenation and Addition 1. Println (10 +2) Type of 2 is Number – Addition -- result : 12 2. Println (10 + “2”) Type of 2 is String – Concatenation --result : 102
  • 5. Confusing single and double quotes 1. Println ('Two’); -- result is Two 2. Println ("Two's"); -- result is Two’s 3. Println ('Two's'); -- Error
  • 6. Variable without - var • JavaScript is very permissive. • It will silently declare it for you globally. • Memory Leakage. • Significantly reduce the chance of bad interactions with other applications libraries.
  • 7. Differentiate float numbers from integer numbers • Example: var myNumber = 3.5; var myResult = 3.5 + 1.0; //We use .0 to keep the result as float 1. No difference between float and integers. 2. Don’t use decimals to “convert” numbers to floats. var myNumber = 3.5; var myResult = 3.5 + 1; //Result is 4.5, as expected
  • 8. Don't Use Short Hand • Curly braces should be omitted is with one-liners. Example: if(someVariableExists) x = false anotherFunctionCall(); It means: if(someVariableExists) { x = false; } anotherFunctionCall();
  • 9. Missing HasOwnProperty for Object • Example : for(key in object) { variable = object[key] ; // includes object properties } } • Solution: for(key in object) { if(object.hasOwnProperty(key) { ...then do something... } }
  • 10. Eval is Evil. • Give Access to JavaScript Compiler. • Debug message arising from Eval are unsearchable. • Eval (String Parameter) then , – Decrease Performance – Huge Security Risk .
  • 11. Undefined Property • Example: var object ={ key1 = {}, key2 = undefined } - Running loop for checking existence of an elements typeof object [key1] = object, typeof object [key2] = undefined typeof object [key3] = undefined • Solution: key2 = null
  • 12. Misuse of Closures • Example: function(a, b, c) { var d = 10; function test (a,b,c,d){ return a+b+c+d; }} • Solution: function(a, b, c) { var d = 10; function test (){ return a+b+c+d; }}
  • 13. Conditional Statements • Example: 1. If(var1 = var2 ) // Assignment -- if (var 1 == var 2) 1. for(var i=0;i<10;i) // execute in infinite loop -- for (var i=0;i<10;i++) 1. for (var i=0;i< Array.length;i++) -- var arrLen = Array.length; for(var 1=0;i<arrlen; i++)
  • 14. Overwriting/Overloading function • Overloading : Declare function more than Once with different arguments. • No function overloading in JavaScript. • Last compiled function definition is used. • This behavior is different from other Programming Language. Example : -function test (param1) - function test (param1, param2)
  • 15. Missing Parameter • Forgot to update to function calls when new parameter add in function. • Example: – function(param1, param2){} – Add new parameter Param3 – function (param1,param2,param3){ param3 = param3 II Default Value }
  • 16. JavaScript Code Quality Tools • Firebug • Firebug is an extremely popular and well- regarded front-end debugging tool. • Drosera Drosera is an excellent debugging tool for Safari and WebKit-based browsers. • NitobiBug NitobiBug is a browser-based JavaScript object logger and inspector