SlideShare a Scribd company logo
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 (20)

ODP
Groovy Ast Transformations (greach)
HamletDRC
 
PDF
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
WebStackAcademy
 
PDF
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
PDF
Pavel kravchenko obj c runtime
DneprCiklumEvents
 
PDF
A Re-Introduction to JavaScript
Simon Willison
 
PDF
Clean code
Arturo Herrero
 
PDF
Zhongl scala summary
lunfu zhong
 
PPT
Data Flow Modeling
Padmanaban Kalyanaraman
 
PPTX
Automatically Documenting Program Changes
Ray Buse
 
PDF
javascript objects
Vijay Kalyan
 
PPTX
TDD Training
Manuela Grindei
 
PPTX
VHDL Behavioral Description
Sudhanshu Janwadkar
 
PDF
Solid scala
Knoldus Inc.
 
PDF
block
Ma Xuebin
 
PPTX
NDC 2011, C++ 프로그래머를 위한 C#
tcaesvk
 
PDF
JavaScript objects and functions
Victor Verhaagen
 
PPTX
Functions and Objects in JavaScript
Dhananjay Kumar
 
PPSX
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
PPTX
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
PPTX
12. Java Exceptions and error handling
Intro C# Book
 
Groovy Ast Transformations (greach)
HamletDRC
 
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
WebStackAcademy
 
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
Pavel kravchenko obj c runtime
DneprCiklumEvents
 
A Re-Introduction to JavaScript
Simon Willison
 
Clean code
Arturo Herrero
 
Zhongl scala summary
lunfu zhong
 
Data Flow Modeling
Padmanaban Kalyanaraman
 
Automatically Documenting Program Changes
Ray Buse
 
javascript objects
Vijay Kalyan
 
TDD Training
Manuela Grindei
 
VHDL Behavioral Description
Sudhanshu Janwadkar
 
Solid scala
Knoldus Inc.
 
block
Ma Xuebin
 
NDC 2011, C++ 프로그래머를 위한 C#
tcaesvk
 
JavaScript objects and functions
Victor Verhaagen
 
Functions and Objects in JavaScript
Dhananjay Kumar
 
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
12. Java Exceptions and error handling
Intro C# Book
 

Similar to JavaScript Common Mistake (20)

PPTX
JavaScript Proven Practises
Robert MacLean
 
PDF
Javascript - Tutorial
adelaticleanu
 
PPT
Javascript
vikram singh
 
PPT
Javascript
Sunil Thakur
 
PPTX
Cordova training : Day 3 - Introduction to Javascript
Binu Paul
 
PPT
Les origines de Javascript
Bernard Loire
 
PPT
The JavaScript Programming Language
Raghavan Mohan
 
PPT
The Java Script Programming Language
zone
 
PPT
Javascript
guest03a6e6
 
PPT
Javascript by Yahoo
birbal
 
PPT
13665449.ppt
JP Chicano
 
PPTX
Unit - 4 all script are here Javascript.pptx
kushwahanitesh592
 
PDF
13 javascript techniques to improve your code
Surendra kumar
 
PDF
The top 5 JavaScript issues in all our codebases
Phil Nash
 
PDF
Js c1 best practices
Ernesto Esparaquia
 
PPTX
Learning space presentation1 learn Java script
engmk83
 
PDF
Javascript basics
shreesenthil
 
PPT
Javascript
vikram singh
 
PPT
Ajax and JavaScript Bootcamp
AndreCharland
 
PPTX
Java script.pptx v
22x026
 
JavaScript Proven Practises
Robert MacLean
 
Javascript - Tutorial
adelaticleanu
 
Javascript
vikram singh
 
Javascript
Sunil Thakur
 
Cordova training : Day 3 - Introduction to Javascript
Binu Paul
 
Les origines de Javascript
Bernard Loire
 
The JavaScript Programming Language
Raghavan Mohan
 
The Java Script Programming Language
zone
 
Javascript
guest03a6e6
 
Javascript by Yahoo
birbal
 
13665449.ppt
JP Chicano
 
Unit - 4 all script are here Javascript.pptx
kushwahanitesh592
 
13 javascript techniques to improve your code
Surendra kumar
 
The top 5 JavaScript issues in all our codebases
Phil Nash
 
Js c1 best practices
Ernesto Esparaquia
 
Learning space presentation1 learn Java script
engmk83
 
Javascript basics
shreesenthil
 
Javascript
vikram singh
 
Ajax and JavaScript Bootcamp
AndreCharland
 
Java script.pptx v
22x026
 
Ad

Recently uploaded (20)

PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Python basic programing language for automation
DanialHabibi2
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Ad

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