Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Javascript Pitfalls
Search
Breno Oliveira
May 20, 2016
Programming
97
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Javascript Pitfalls
Javascript Pitfalls
Breno Oliveira
May 20, 2016
More Decks by Breno Oliveira
See All by Breno Oliveira
Spring e Eureka Service Discovery
brenooliveira
0
64
Como Fazer Minha Gem e o Rails Conversarem Bem
brenooliveira
0
52
Elasticsearch - Turbinando sua aplicação PHP
brenooliveira
1
160
Elasticsearch
brenooliveira
1
120
Falando sobre testes automatizados
brenooliveira
0
94
Other Decks in Programming
See All in Programming
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
240
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
200
はてなアカウント基盤 State of the Union
cockscomb
1
1.1k
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.5k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
スマートグラスで並列バイブコーディング
hyshu
0
270
Vite+ Unified Toolchain for the Web
naokihaba
0
370
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
130
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
200
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
Featured
See All Featured
The agentic SEO stack - context over prompts
schlessera
0
830
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
590
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
250
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Test your architecture with Archunit
thirion
1
2.3k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
170
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
240
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
170
Statistics for Hackers
jakevdp
799
230k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
280
Transcript
JAVASCRIPT Pitfalls
Why?
None
Escopos • Global or FuckingScope • Functions • IIFE (Immediately
Invoked Function Expression)
Global var chauehGlobal = "Chaue Ferradura"
Local var chauehGlobal = "Chaueh Ferradura"; function scope1() { var
chauehLocal = "Chaueh é Legal"; } scope1(); console.log(chauehLocal); //Arrrggg ... Reference Error
var chauehGlobal = "Chaueh Ferradura"; function scope1() { var chauehLocal
= "Chaueh é Legal"; function scope2() { var chauehLocal = "Chaueh é Chato"; console.log(chauehLocal); // é Chato } console.log(chauehLocal); // é legal }
IIFE (function(){ var local = "Chaueh é Fofo"; })(); console.log(local);
// Reference Error
javascript hoisting
– Chaueh Ferradura “JavaScript Hoisting é o comportamento default de
mover declarações a o top.”
hoisting(); // Nooooooooooooooooo function chamaChaueh() { console.log("Nooooooooooooooooo") }
function chamaChaueh() { console.log("Nooooooooooooooooo") } hoisting(); // Nooooooooooooooooo
console.log(ops); // ??? (Gui? Gabi? Wil? Alguém arrisca?) var ops
= "Chama Chaueh";
Fuck vou embora
Declare suas variáveis no começo
ops(); var ops = function(){ console.log("Chaueh é lindo"); }; Chaueh:
Tá de sacanagem BrenoPHP? Você já mostrou que isso funciona. BrenoPHP: Mostrei Chaueh? Tem certeza? Acho que não
Objetos por referência
var pessoa = { idade: 20 } var chaueh =
pessoa; chaueh.idade = 24; console.log(pessoa.idade); // 24
var pessoa = { idade: 20 } var chaueh =
Object.create(pessoa); chaueh.idade = 24; console.log(pessoa.idade); // 20 object.create
.has Own Property
var chaueh = { nome: "Chaueh Ferradura", idade: 24, sexo:
"M" } chaueh.hasOwnProperty("nome"); // true chaueh.hasOwnProperty("religiao"); // false
== ≠ ===
("0" == 0) // true ("0" === 0) // false
parseint do demo….
parseInt("08"); // 0 parseInt("08", 10); // 8
String replace
var texto = "Chaueh Ferradura era um cara legal"; texto.replace(/
/, "_"); //Chaueh_Ferradura era um cara legal texto.replace(/ /g, "_"); // Chaueh_Ferradura_era_um_cara_legal
obrigado