forked from b00tc4mp/isdi-parttime-202410
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add array, dorraymon and this folder b00tc4mp#8
- Loading branch information
Showing
4 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
staff/quique-cabrera/playground/array/Array.prototype.at.test.js
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
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) |
24 changes: 24 additions & 0 deletions
24
staff/quique-cabrera/playground/dorraymon/Dorraymon.proptotype.at.test.js
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
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 |
34 changes: 34 additions & 0 deletions
34
staff/quique-cabrera/playground/dorraymon/Dorraymon.prototype.at.test.1.js
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
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 |
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
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]) |