Skip to content

Instantly share code, notes, and snippets.

@aalvesjr
Created September 12, 2011 03:55
Show Gist options
  • Save aalvesjr/1210552 to your computer and use it in GitHub Desktop.
Save aalvesjr/1210552 to your computer and use it in GitHub Desktop.
TestesComJS
var functionTeste = new Function("variavel","texto","alert(variavel+' '+texto)"); //functionTeste('Armando','testando JS!');
var functionTesteDois = new Function("alert('Teste hehehe')"); //functionTesteDois.call();
function photo(nome){
this.name = nome
}
function planet(nome,tamanho,photo){
this.nome = nome
this.tamanho = tamanho
//valores default com '||'
this.photo = photo || "Sem Fotos Disponiveis"
this.desc = new Function( "return this.nome+' : '+this.tamanho"); // alert(terra.desc());
}
// JS::Testes
var photoTerra = new photo('Foto da Terra');
// Criando atraves do Object()
var Earth = new Object()
Earth.nome = "Terra"
Earth.tamanho = "Muy Grande"
Earth.photo = photoTerra
var terra = new planet('Terra','Grande Pra C@#$!%@#%')
//adicionando GETTER and SETTERS
planet.prototype.__defineSetter__("atrb",function(vlr){atrb = vlr})
planet.prototype.__defineGetter__("atrb",function(){return atrb})
terra.atrb = "Get n' Set"
//adicionando metodos dinamicamente
planet.prototype.descricao = "Object::Planet"
var venus = {nome:"AtributosDinamicos",type:"Planet"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment