SlideShare una empresa de Scribd logo
1 de 64
Introdução a JavaScript Marcos Roberto Ferreira marcos.wp@gmail.com @marcoooos
BRAVA ECM Empresa especialista na distribuição e prestação de serviços em soluções de GED/CM, Workflow/BPM, Qualidade e Portais, que conta com a credibilidade de ser uma empresa com o selo TOTVS Business Partner. 10 anos de atuação no mercado + de 1.000 projetos entregues + de 1.000.000 horas  aplicadas em projetos Equipe certificada e altamente qualificada para atendimento em toda a América Latina
Programação Motivação O que é JS Tipos de dados Funções Objetos Escopo de execução Eventos Melhores práticas Ajax Bibliotecas 3
Qual é nossa BRAVA missão? 4
Elevar a geração de resultados de nossos clientes através da automação e gestão de seus processos.
Qual a principal arma para cumprir nossa missão? 6
7
ByYou ECM 8
E como podemos nos diferenciar na utilização do ByYou ECM? 9
Datasets 10
Workflows 11
Fichários 12
Fichários? 13
14
HTML... 15
HTML CSS JavaScript 16
Mas o que é JavaScript? 17
18 JavaScripté umaimplementação do ECMAScript. Pode ser caracterizadapor ser dinâmica,fracamentetipada,orientada a objetos, baseadaemprototypeefirst-class function
19 Na web, JavaScript é utilizado para criarinteração com páginas HTML através da manipulação do Document Object Model (DOM) Após o advento do AJAX, JavaScript se tornouuma das principaisferramentasnaconstrução da Web 2.0
20 Document Object Model (DOM) <script type="text/javascript"> 	/* aqui fica o script */ </script> <script type="text/javascript“ src=“lib.js”> </script>
21 Document Object Model (DOM)
22 Document Object Model (DOM) ,[object Object]
x.getElementsByTagName(name
x.appendChild(node)
x.removeChild(node),[object Object]
24 ,[object Object]
Strings (“forty two”, “”)
Booleans (true, false)
Objects ( {}, { foo: “bar”} )
Functions (alert, eval)
null
undefined,[object Object]
26 typeof(null); //object typeof(undefined); // undefined typeof(NaN); // number
27 var a = null; alert(a) // null var a; alert(a); // undefined var a = 0/0 alert(a) // NaN
28 ? var a = 10/0 alert(a)
29 var a = 10/0 alert(a) // Infinity
30 a == b vs a === b
? ,[object Object]
0 == “”
0 == “0”
false == “false”
false == “0”
false == undefined
false == null
null == undefined
“  ” == 0		,[object Object]
0 == “”				// true
0 == “0”				// true
false == “false”		// false
false == “0”			// true
false == undefined		// false
false == null			// false
null == undefined		// true
“  ” == 0		// true,[object Object]
0 === “”				// false
0 === “0”				// false
false === “false”		// false
false === “0”			// false
false === undefined	// false
false === null			// false
null === undefined		// false
“  ” === 0		// false‘’ === ‘0’			// false 0 === ‘’			// false 0 === ‘0’			// false false === ‘false’	// false false === ‘0’		// false false === undefined	// false false === null		// false null === undefined	// false “  ” === 0	// false
Funções 34
Declaração de uma função ‘’ === ‘0’			// false 0 === ‘’			// false 0 === ‘0’			// false false === ‘false’	// false false === ‘0’		// false false === undefined	// false false === null		// false null === undefined	// false “  ” === 0	// false functionnomeDaFuncao(var1,var2,...,varX){	linha de código 1 	linha de código 2 	linha de código 3 } Chamada de uma função function soma(num1, num2){ alert(num1+num2); } soma(1, 1);

Más contenido relacionado

Similar a Developer day 2010 - javascript

Combinando OO e Funcional em javascript de forma prática
Combinando OO e Funcional em javascript de forma práticaCombinando OO e Funcional em javascript de forma prática
Combinando OO e Funcional em javascript de forma práticaMilfont Consulting
 
Apresentacao codeigniter
Apresentacao codeigniterApresentacao codeigniter
Apresentacao codeigniterAndré Tagliati
 
Javascript The good, bad and ugly parts
Javascript The good, bad and ugly partsJavascript The good, bad and ugly parts
Javascript The good, bad and ugly partsFabian Carlos
 
Da argila ao forte: como desenvolver uma loja com PagSeguro
Da argila ao forte: como desenvolver uma loja com PagSeguroDa argila ao forte: como desenvolver uma loja com PagSeguro
Da argila ao forte: como desenvolver uma loja com PagSeguroMichael Castillo Granados
 

Similar a Developer day 2010 - javascript (6)

Java script aula 02 - operadores
Java script   aula 02 - operadoresJava script   aula 02 - operadores
Java script aula 02 - operadores
 
Combinando OO e Funcional em javascript de forma prática
Combinando OO e Funcional em javascript de forma práticaCombinando OO e Funcional em javascript de forma prática
Combinando OO e Funcional em javascript de forma prática
 
Beagajs
BeagajsBeagajs
Beagajs
 
Apresentacao codeigniter
Apresentacao codeigniterApresentacao codeigniter
Apresentacao codeigniter
 
Javascript The good, bad and ugly parts
Javascript The good, bad and ugly partsJavascript The good, bad and ugly parts
Javascript The good, bad and ugly parts
 
Da argila ao forte: como desenvolver uma loja com PagSeguro
Da argila ao forte: como desenvolver uma loja com PagSeguroDa argila ao forte: como desenvolver uma loja com PagSeguro
Da argila ao forte: como desenvolver uma loja com PagSeguro
 

Último

Boas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsBoas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsDanilo Pinotti
 
Luís Kitota AWS Discovery Day Ka Solution.pdf
Luís Kitota AWS Discovery Day Ka Solution.pdfLuís Kitota AWS Discovery Day Ka Solution.pdf
Luís Kitota AWS Discovery Day Ka Solution.pdfLuisKitota
 
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docxATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx2m Assessoria
 
Programação Orientada a Objetos - 4 Pilares.pdf
Programação Orientada a Objetos - 4 Pilares.pdfProgramação Orientada a Objetos - 4 Pilares.pdf
Programação Orientada a Objetos - 4 Pilares.pdfSamaraLunas
 
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docxATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx2m Assessoria
 
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docxATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx2m Assessoria
 
Padrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploPadrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploDanilo Pinotti
 
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docxATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx2m Assessoria
 

Último (8)

Boas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsBoas práticas de programação com Object Calisthenics
Boas práticas de programação com Object Calisthenics
 
Luís Kitota AWS Discovery Day Ka Solution.pdf
Luís Kitota AWS Discovery Day Ka Solution.pdfLuís Kitota AWS Discovery Day Ka Solution.pdf
Luís Kitota AWS Discovery Day Ka Solution.pdf
 
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docxATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
ATIVIDADE 1 - ESTRUTURA DE DADOS II - 52_2024.docx
 
Programação Orientada a Objetos - 4 Pilares.pdf
Programação Orientada a Objetos - 4 Pilares.pdfProgramação Orientada a Objetos - 4 Pilares.pdf
Programação Orientada a Objetos - 4 Pilares.pdf
 
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docxATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
 
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docxATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
 
Padrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploPadrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemplo
 
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docxATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
 

Developer day 2010 - javascript

  • 1. Introdução a JavaScript Marcos Roberto Ferreira marcos.wp@gmail.com @marcoooos
  • 2. BRAVA ECM Empresa especialista na distribuição e prestação de serviços em soluções de GED/CM, Workflow/BPM, Qualidade e Portais, que conta com a credibilidade de ser uma empresa com o selo TOTVS Business Partner. 10 anos de atuação no mercado + de 1.000 projetos entregues + de 1.000.000 horas aplicadas em projetos Equipe certificada e altamente qualificada para atendimento em toda a América Latina
  • 3. Programação Motivação O que é JS Tipos de dados Funções Objetos Escopo de execução Eventos Melhores práticas Ajax Bibliotecas 3
  • 4. Qual é nossa BRAVA missão? 4
  • 5. Elevar a geração de resultados de nossos clientes através da automação e gestão de seus processos.
  • 6. Qual a principal arma para cumprir nossa missão? 6
  • 7. 7
  • 9. E como podemos nos diferenciar na utilização do ByYou ECM? 9
  • 14. 14
  • 17. Mas o que é JavaScript? 17
  • 18. 18 JavaScripté umaimplementação do ECMAScript. Pode ser caracterizadapor ser dinâmica,fracamentetipada,orientada a objetos, baseadaemprototypeefirst-class function
  • 19. 19 Na web, JavaScript é utilizado para criarinteração com páginas HTML através da manipulação do Document Object Model (DOM) Após o advento do AJAX, JavaScript se tornouuma das principaisferramentasnaconstrução da Web 2.0
  • 20. 20 Document Object Model (DOM) <script type="text/javascript"> /* aqui fica o script */ </script> <script type="text/javascript“ src=“lib.js”> </script>
  • 21. 21 Document Object Model (DOM)
  • 22.
  • 25.
  • 26.
  • 29. Objects ( {}, { foo: “bar”} )
  • 31. null
  • 32.
  • 33. 26 typeof(null); //object typeof(undefined); // undefined typeof(NaN); // number
  • 34. 27 var a = null; alert(a) // null var a; alert(a); // undefined var a = 0/0 alert(a) // NaN
  • 35. 28 ? var a = 10/0 alert(a)
  • 36. 29 var a = 10/0 alert(a) // Infinity
  • 37. 30 a == b vs a === b
  • 38.
  • 46.
  • 54.
  • 62. “ ” === 0 // false‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false
  • 64. Declaração de uma função ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false functionnomeDaFuncao(var1,var2,...,varX){ linha de código 1 linha de código 2 linha de código 3 } Chamada de uma função function soma(num1, num2){ alert(num1+num2); } soma(1, 1);
  • 65. Propriedades de uma função ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false arguments – parâmetrospassados para a função caller – funçãoqueestáchamando a função. prototype – utilizado para adicionaratributosoufunções. Retorno de uma função function soma(num1, num2){ return num1+num2; } var resultado = soma(1, 1); alert(resultado);
  • 67. Template de Objeto ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false functionPerson(firstName, lastName) { this.name = firstName; if(lastName==undefined){ this.name = "Sr." + this.name; } this.sayHello = function(){ alert("hello: " + this.name); } this.sayGoodbye = function () { alert("goodbye: " + this.name); } } var p = newPerson("Marcos", "Ferreira"); p.sayHello(); p.sayGoodbye();
  • 68. Instância direta de Objeto ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false var person = newObject(); person.name = "Marcos"; person.sayHello = function() { alert("hello: " + this.name); } person.sayGoodbye = function() { alert("goodbye: " + this.name); } person.sayHello(); person.sayGoodbye();
  • 69. Objeto com notação literal ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false var person = { name:"marcos", idade:25, email: “marcos.wp@gmail.com”, sayHello:function(){ alert("hello: " +name) }, sayGoodbye:function(){ alert("goodbye: " + name) } } person.sayHello(); person.sayGoodbye();
  • 70. Herança com funções ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false functionPerson(firstName) { this.name = firstName; this.sayHello = function() { ... } this.sayGoodbye = function() { ... } } functionStudent(studentName){ this.inheritFrom = Person; this.inheritFrom(studentName); this.sayHello = function(){ ... } } var p = newStudent("Marcos"); p.sayHello(); p.sayGoodbye();
  • 71. Herança com Prototype ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false functionPerson(firstName, lastName) { this.name = firstName; this.sayHello = function() { ... } this.sayGoodbye = function() { ... } } functionStudent(studentName){ this.name = studentName; this.sayHello = function(){ ... } } Student.prototype = newPerson; var p = newStudent("Marcos"); p.sayHello(); p.sayGoodbye();
  • 73. Atributo de objeto function escopo() { this.var1 = "um valor"; this.fazAlgo = function (){ alert(this.var1); // um valor } } new escopo().fazAlgo(); alert(this.var1) //undefined
  • 74. Variáveis locais functionfazAlgo() { var var1 = "um valor"; alert(var1); // um valor } fazAlgo(); alert(var1); //var1 is notdefined
  • 75. Variáveis globais ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false functionfazAlgo() { var1 = "um valor"; alert(var1); // um valor } fazAlgo(); alert(var1); // um valor
  • 77. onFocus, onBlur, onChange <input type="text" id="email" onchange="checkEmail()"> onSubmit <form action="xxx.htm" onsubmit="return checkForm()"> onMouseOver, onMouseOut <a href=“..." onmouseover="alert(‘hello')">hello</a> ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false
  • 78. ‘’ === ‘0’ // false 0 === ‘’ // false 0 === ‘0’ // false false === ‘false’ // false false === ‘0’ // false false === undefined // false false === null // false null === undefined // false “ ” === 0 // false Boas práticas
  • 79. function foo() { return { bar: 42 }; } function foo() { return { bar: 42 }; }
  • 80. function foo() { return { bar: 42 }; } alert(foo()); // object alert(foo().bar); // 42 function foo() { return { bar: 42 }; } alert(foo()); // undefined
  • 81. function foo() { return { bar: 42 }; } function foo() { return; { bar: 42; }; } Adicionado automáticamente
  • 82.
  • 83.
  • 84. // javascript if (true) { (function () { var x = 10; }()); } alert(x); // undefined // javascript if (true) { var x = 10; } alert(x); // 10
  • 85. // javascript if (true) { (function () { var x = 10; }()); } alert(x); // undefined // javascript if (true) { (function () { x = 10; }()); } alert(x); // 10
  • 86.
  • 87.
  • 88.
  • 89.
  • 92. Referências http://www.slideshare.net/cheilmann/javascript-best-practices-1041724 http://www.slideshare.net/thomanil/javascript-neednt-hurt-javabin-talk http://www.w3schools.com/js/default.asp http://www.w3schools.com/htmldom/default.asp http://www.slideshare.net/Dmitry.Baranovskiy/java-script-workshop

Notas del editor

  1. Brackets go on the same line, that’s not negotiable!Can you tell the difference between the two codes?What’s gonna be the result of the function foo in each case?Analogy with which side of the street you pick
  2. Brackets go on the same line, that’s not negotiable!Can you tell the difference between the two codes?What’s gonna be the result of the function foo in each case?Analogy with which side of the street you pick