Skip to content

Instantly share code, notes, and snippets.

View pamplonafala's full-sized avatar

Matheus Pamplona pamplonafala

  • Brasil - São Paulo /SP
View GitHub Profile
@pamplonafala
pamplonafala / user.js
Created August 8, 2017 18:53 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@pamplonafala
pamplonafala / comparison.js
Created July 26, 2017 14:25 — forked from SegersIan/comparison.js
literal objects(literals) vs constructor functions vs factory functions
// Factory function/method
function factoryFunction (){
return {
field : 'value',
method : function() { return 5; }
}
}
const myNewObjectA = factoryFunction();
// Constructor Function
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="_css/estilo.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="_js/javascript.js"></script>
<script src="_js/jQuery.js"></script>
<title>Home</title>
<style id="jsbin-css">