This file contains hidden or 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
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander']; | |
const morePokemon = ['Totodile', 'Chikorita', 'Cyndaquil']; | |
const pokedex = [...pokemon, ...morePokemon]; | |
console.log(pokedex); //Result: [ 'Squirtle', 'Bulbasur', 'Charmander', 'Totodile', 'Chikorita', 'Cyndaquil' ] |
This file contains hidden or 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
const pokemon = [ | |
{ name: 'Squirtle', type: 'Water' }, | |
{ name: 'Bulbasur', type: 'Plant' }]; | |
const morePokemon = [{ name: 'Charmander', type: 'Fire' }]; | |
const pokedex = [...pokemon, ...morePokemon]; | |
console.log(pokedex); //Result: [ { name: 'Squirtle', type: 'Water' }, { name: 'Bulbasur', type: 'Plant' }, { name: 'Charmander', type: 'Fire' } ] |
This file contains hidden or 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
const pokemon = ['Squirtle', 'Bulbasur']; | |
const charmander = 'Charmander'; | |
const cyndaquil = 'Cyndaquil'; | |
const pokedex = [...pokemon, charmander, cyndaquil]; | |
console.log(pokedex); //Result: [ 'Squirtle', 'Bulbasur', 'Charmander', 'Cyndaquil' ] |
This file contains hidden or 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
const numbers = [1, 2, 3]; | |
console.log(...numbers); //Result: 1 2 3 | |
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander']; | |
console.log(...pokemon); //Squirtle Bulbasur Charmander | |
const pokedex = [ | |
{ name: 'Squirtle', type: 'Water' }, | |
{ name: 'Bulbasur', type: 'Plant' }, | |
{ name: 'Charmander', type: 'Fire' } |
This file contains hidden or 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
const basicSquirtle = { name: 'Squirtle', type: 'Water' }; | |
const fullSquirtle = { | |
...basicSquirtle, | |
species: 'Tiny Turtle Pokemon', | |
evolution: 'Wartortle' | |
}; | |
console.log(fullSquirtle); //Result: { name: 'Squirtle', type: 'Water', species: 'Tiny Turtle Pokemon', evolution: 'Wartortle' } |
This file contains hidden or 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
const mySquirtle = { | |
name: 'Squirtle', | |
type: 'Water', | |
hp: 100 | |
}; | |
const anotherSquirtle = mySquirtle; | |
anotherSquirtle.hp = 0; | |
console.log(mySquirtle); //Result: { name: 'Squirtle', type: 'Water', hp: 0 } |
This file contains hidden or 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
const mySquirtle = { | |
name: 'Squirtle', | |
type: 'Water', | |
hp: 100 | |
}; | |
const anotherSquirtle = { ...mySquirtle }; | |
anotherSquirtle.hp = 0; | |
console.log(anotherSquirtle); //Result: { name: 'Squirtle', type: 'Water', hp: 0 } |
This file contains hidden or 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
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander']; | |
const pokedex = [...pokemon]; | |
pokedex.push('Cyndaquil'); | |
console.log(pokemon); //[ 'Squirtle', 'Bulbasur', 'Charmander' ] | |
console.log(pokedex); //[ 'Squirtle', 'Bulbasur', 'Charmander', 'Cyndaquil' ] |
This file contains hidden or 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
const baseSquirtle = { | |
name: 'Squirtle', | |
type: 'Water' | |
}; | |
const squirtleDetails = { | |
species: 'Tiny Turtle Pokemon', | |
evolution: 'Wartortle' | |
}; |
This file contains hidden or 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
const nodeList = document.getElementsByClassName("pokemon"); | |
const array = [...nodeList]; | |
console.log(nodeList); //Result: HTMLCollection [ div.pokemon, div.pokemon ] | |
console.log(array); //Result: Array [ div.pokemon, div.pokemon ] |
OlderNewer