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
| // By default, Set compares JS object references | |
| const myObject = { hello: "🌞" } | |
| const objectsArray = [myObject, myObject] | |
| const objectsSet = new Set(objectsArray) | |
| const uniqueObjectReferences = Array.from(objectsSet) | |
| // Equivalent to: (using the spread operator) | |
| // const uniqueObjectReferences = [...objectsSet] | |
| console.log(objectsArray) | |
| // Output: [ { hello: "🌞" }, { hello: "🌞" } ] |
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
| import React, { Component } from "react" | |
| export default class EmojifyComponent extends Component { | |
| constructor(props) { | |
| super(props) | |
| } | |
| render({ name, emoji }) { | |
| return ( | |
| <h1> |
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
| import React from "react" | |
| const EmojifyComponent = ({ name, emoji }) => { | |
| return ( | |
| <h1> | |
| {emoji} {name} {emoji} | |
| </h1> | |
| ) | |
| } | |
| export default EmojifyComponent |
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
| import React, { Component } from "react" | |
| export default class EmojifyComponent extends Component { | |
| constructor(props) { | |
| super(props) | |
| } | |
| render() { | |
| const { name, emoji } = this.props | |
| return ( |
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
| import React from "react" | |
| const EmojifyComponent = (props) => { | |
| return ( | |
| <h1> | |
| {props.emoji} {props.name} {props.emoji} | |
| </h1> | |
| ) | |
| } | |
| export default EmojifyComponent |
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
| import React from "react" | |
| const EmojifyComponent = (props) => { | |
| const { name, emoji } = props | |
| return ( | |
| <h1> | |
| {emoji} {name} {emoji} | |
| </h1> | |
| ) | |
| } | |
| export default EmojifyComponent |
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 myObject = { hello: "👋" } | |
| const { hello } = myObject | |
| console.log(hello) // Output: 👋 | |
| myObject.hello === hello // true |
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 [name, setName] = useState("Stanny Staunton") | |
| // useState returns an array with two elements | |
| // Array destructuring is a briefer syntax for this code: | |
| const arrayFromUseState = useState("Stanny Staunton") | |
| const nameInState = arrayFromUseState[0] | |
| const setNameInState = arrayFromUseState[1] | |
| // The above code is equivalent to: | |
| const [name2, setName2] = arrayFromUseState |
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
| <ChildComponent name="Stanny Staunton" email="stanDaMan@stan.com" /> |
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 arrayToJoin2 = ["😄", "😄", "😄"] | |
| // comma and a space | |
| arrayToJoin2.join(", ") | |
| // Output: "😄, 😄, 😄" |