This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Escopo Global | |
var nome = "Robson"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery('#modal').hide(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<script> | |
var MinhaBibliotecaGlobal = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nome = 'Robson'; | |
var escopo1 = function () { | |
// nome é visível aqui | |
var escopo2 = function () { | |
// nome é visível aqui também | |
var escopo3 = function () { | |
// nome também é visível aqui | |
}; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(a) { | |
//var a = 2; //é como se a estivesse no escopo de foo | |
var b = a * 2; | |
function bar(c) { | |
//var c = b * 3; //é como se c estivesse no escopo de bar | |
console.log( a, b, c ); | |
} | |
bar( b * 3 ); | |
} | |
foo( 2 ); // 2, 4, 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cliente { | |
private Date dataCriacao; | |
public Date getDataCriacao() { | |
return this.dataCriacao; | |
} | |
} | |
Cliente cli = new Cliente(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public class InstantTeste { | |
public static void main(String args[]) { | |
Instant t1 = Instant.now(); | |
System.out.println(t1); | |
Instant t2 = t1.plusSeconds(10); | |
System.out.println("T1 + 10s: " + t2); | |
Instant t3 = t2.minusSeconds(10); | |
System.out.println("T2 - 10s: " + t3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TempoExecucao() { | |
public static void main(String args[]) { | |
Long t1 = System.currenttimemillis(); | |
metodoDemorado(); | |
Long t2 = System.currenttimemillis(); | |
Long tempo = (t2-t1)/1000; | |
System.out.println("Tempo total: " + tempo); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TempoExecucao() { | |
public static void main(String args[]) { | |
Instant inicio = Instant.now(); | |
metodoDemorado(); | |
Instant fim = Instant.now(); | |
Duration tempoTotal = Duration.between(inicio, fim); | |
long millis = tempoTotal.toMillis(); | |
long min = tempoTotal.toMinutes(); | |
long sec = tempoTotal.getSeconds(); //foge o padrão :) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public class Durations { | |
public static void main(String[] args) { | |
//Meu algoritmo padrão rodou em 5000 milisegundos | |
Duration algoritmo1 = Duration.ofMillis(5000); | |
Instant t1 = Instant.now(); | |
algoritmo2(); |
OlderNewer