Skip to content

Instantly share code, notes, and snippets.

View moisescastillo's full-sized avatar

moisescastillo

View GitHub Profile
@moisescastillo
moisescastillo / JS_object_instance.js
Created July 19, 2020 21:05
Javascript object instances
function Person(name) {
this.name = name;
this.greeting = function() {
console.log(`Hi I'm ${this.name}`);
}
}
let person1 = new Person('Peter');
let person2 = new Person('Sarah');
@moisescastillo
moisescastillo / JS_object_basic.js
Created July 19, 2020 01:09
JavaScript object basic
const person = {
name: {first:'Bob', last: 'Smith'},
age: 32,
gender: 'male',
interests: ['Music', 'Boxing'],
greeting: function() {
console.log(`Hi, I\'m ${this.name.first}`);
},
fullName: function() {
console.log(`${this.name.first} ${this.name.last}`);
@moisescastillo
moisescastillo / JS_call.js
Last active July 11, 2020 22:21
JavaScript Function Call
// JavaScript Function Call
let person = {
bio: function() {
return `Name: ${this.name}, Age: ${this.age}`;
}
}
function greeting(message) {
return `${this.name} : ${message}`;
@moisescastillo
moisescastillo / JS_map.js
Last active July 11, 2020 23:45
JavaScript map method
// JS: map() method
let clientes = [
{nombre: "Luis", edad: 22},
{nombre: "Alberto", edad: 31},
{nombre: "Eduardo", edad: 19}
];
let foo = clientes.map(function(cliente) {
return cliente.nombre;