Skip to content

Commit

Permalink
add array, dorraymon and this folder b00tc4mp#8
Browse files Browse the repository at this point in the history
  • Loading branch information
frameloop committed Oct 19, 2024
1 parent 014df53 commit 90fa5a8
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
33 changes: 33 additions & 0 deletions staff/quique-cabrera/playground/array/Array.prototype.at.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
console.log('TEST Array.prototype.at')

console.log('CASE getelement at index 3')

//var cars = ['lambo', 'f350', '911', 'm5','hummer']
var cars = new Array
cars[0] = 'lambo'
cars[1] = 'f350'
cars[2] = '911'
cars[3] = 'm5'
cars[4] = 'hummer'
var car = cars.at(3)
console.log(car)
// m5

console.log('CASE get item at -10')

var cart = new Array
cart[0] = { brand: 'Adidas', model: 'Niza', size: 43, price: 70, quantity: 2 }
cart[1] = { brand: 'Puma', model: 'Gatito', size: 'L', price: 20, quantity: 3 }
cart[2] = { brand: 'Nike', model: 'Chachi', size: '44', price: 15, quantity: 6 }
var item = cart.at(-10)
console.log(item)
//undefined

console.log('CASE get item at 10')

var cart = new Array
cart[0] = { brand: 'Adidas', model: 'Niza', size: 43, price: 70, quantity: 2 }
cart[1] = { brand: 'Puma', model: 'Gatito', size: 'L', price: 20, quantity: 3 }
cart[2] = { brand: 'Nike', model: 'Chachi', size: 44, price: 12, quantity: 6 }
var item = cart.at(10)
console.log(item)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function Dorraymon() {
this.length = 0

Dorraymon.prototype.at = function (index) {
if (index < 0) {
var newIndex = this.length + index
return this[newIndex]
} else return this[index]
}

console.log('TEST Dorraymon.prototype.at')

console.log('CASE get car at index 3')

var cars = new Dorraymon
cars[0] = 'lambo'
cars[1] = 'f350'
cars[2] = '911'
cars[3] = 'm5'
cars[4] = 'hummer'
cars.length = 5
var car = cars.at(3)
console.log(car)
// m5
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function Dorraymon() {
this.length = 0
}

Dorraymon.prototype.at = function (index) {
return this[index]
}

console.log('TEST Dorraymon.prototype.at')

console.log('CASE get car at index 3')

var cars = new Dorraymon
cars[0] = 'lambo'
cars[1] = 'f350'
cars[2] = '911'
cars[3] = 'm5'
cars[4] = 'hummer'
cars.length = 5
var car = cars.at(3)
console.log(car)
//m5

console.log('CASE get functionat index 2')

var funs = new Dorraymon
funs[0] = function () { return 'Zero' }
funs[1] = function () { return 'One' }
funs[2] = function () { return 'Two' }
funs[3] = function () { return 'Three' }
funs.length = 4
var fun = funs.at(2)
console.log(fun())
//Two
74 changes: 74 additions & 0 deletions staff/quique-cabrera/playground/this/This.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
var a = ['coche', 'perro', 'casa', 'gato']



window.name = 'Window'
window.image = '🫥'
var peter = { name: 'Peter', image: '🥵' }
var wendy = { name: 'Wendy', image: '🥶' }
peter.weapon = '🔫'
wendy.weapon = '👙'

function hello() {
return this.image + ' ' + this.name + ': Hello!' + ' ' + this.weapon
}

/*console.log(hello())
console.log(hello.call(peter))
console.log(window.hello.call(peter))
console.log(hello.call(wendy))*/

wendy.hi = hello
peter.ciao = hello

a.name = 'caja'
a.image = '📦'
a.weapon = '💣'
a.hola = hello
a[10] = peter
peter.partner = wendy
wendy.partner = peter

/*console.log(wendy.hi())
console.log(peter.ciao())
console.log(a.hola())
console.log(a.length)
console.log(a.hola())
console.dir(a)
console.log(a[10].ciao())*/


/*var f =function a(){
return function b(){
return [,,function c(){
return {
o:{
hi: function(){
return 'hi!'
}
}
}
}]
}
}
console.log(f()()[2]().o.hi())*/

var g = ['hola', 1, true, {
},
{
0: [, , , , {
b: function () {
return
{
c: function() {
return [function () { return 'yo' }]
}
}
}
}]

}]


console.log(g[4][0][4])

0 comments on commit 90fa5a8

Please sign in to comment.