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
/* | |
* Creating new Objects | |
* https://developer.mozilla.org/pl/docs/Web/JavaScript/Guide/Working_with_Objects | |
*/ | |
let myObj = new Object(); | |
let myObj = {}; // preffered method | |
let myObj = Object.create(Prototype, {name: 'Foo'}); | |
/** | |
* Adding properties |
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
// Singly Linked List data structure implementation | |
// in javascript. (not all methods) | |
class SinglyListNode { | |
constructor(data) { | |
this.data = data; | |
this.next = null; | |
} | |
} |
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
import styled from 'styled-components'; | |
const HeaderText = styled.h1` | |
font-size: ${ props => props.large ? 32 : 24 }px; | |
color: wheat; | |
text-transform: uppercase; | |
`; | |
export default () => ( | |
<HeaderText large>Looks Cool</HeaderText> |
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
.header__text { | |
font-size: 24px; | |
color: wheat; | |
text-transform: uppercase; | |
&--large { | |
font-size: 32px; | |
} | |
} |
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
import './HeaderText.scss'; | |
export default ({ | |
large, | |
children, | |
className, | |
...props | |
}) => { | |
const classList = `header__text ${large && 'header__text--large'} ${className}`; | |
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
const log = (...args) => console.log(...args); | |
log('This', 'is', 'useless'); | |
// 'This', 'is', 'useless' | |
const name = 'Bob'; | |
log`Hi ${name}! How are you?`; | |
// ['Hi ', '! How are you?'], 'Bob' |
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
( | |
[ 'font-size: 12px ;background-color: ', ';' ], // first argument | |
(props => props.solid ? 'red' : 'blue') | |
) |
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
'font-size: 12px; background-color: ' + 'red' + ';' |
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
// component props mock | |
const properties = { | |
color: 'red', | |
large: true | |
}; | |
// curried function | |
const styled = (props) => (strings, ...args) => { | |
return strings.map((string, i) => { | |
const correspondingItem = args[i]; |
OlderNewer