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
Javascript type | constructor | example values | typescript type | example usage | alternative syntax | |
---|---|---|---|---|---|---|
Boolean | Boolean(1); | true, false | boolean | const isOpen: boolean = true; | ||
Number | Number('1'); | 1, 2 | number | const n: number = 1; | ||
String | String('');, '',", `` | 'ok' | string | const str: string = 'ok'; | ||
Array | new Array(); []; | [1, 2, 3]; | number[]; Array<number>; | const list: number[] = [1, 2, 3]; | const list: Array<number> = [1, 2, 3]; | |
Null | null | null | null | const n: null = null; | ||
Undefined | undefined | undefined | undefined | const u: undefined = undefined; | ||
Object | new Object(); | {key: 'value'}; | object | const item: object = {key: 'value'}; | const item: {[key: string]: string} = {key: 'value'}; | |
['Hello', true]; | Touple | const hi: [string, boolean] = ['Hello', true] | ||||
enum | enum Color {Red, Green, 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
/** | |
* A person object with name, age and sayName method. | |
* @typedef {Object} Person | |
* @property {string} name The person's name. | |
* @property {number} age The person's age. | |
* @property {Function} sayName A function that alerts the person's name. | |
*/ | |
const person = { | |
name: 'Joe', | |
age: 32, |
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 React from "react"; | |
import {inject, observer} from "mobx-react"; | |
export class SubjectsPresenter extends React.Component {...} | |
export default inject( | |
({subjectStore, translator}, {subjectSelections, ...props}) => { | |
const subjectOptions = subjectStore.getFilteredSubjects(subjectSelections); | |
return { | |
subjectOptions, |
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
// see types of prompts: | |
// https://github.com/enquirer/enquirer/tree/master/examples | |
// | |
module.exports = [ | |
{ | |
type: "input", | |
name: "name", | |
message: "What's the name of your package?" | |
}, | |
{ |
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 React from "react"; | |
import ReactDOM from "react-dom"; | |
import Calendar from "./components/Calendar"; | |
const App = () => ( | |
<> | |
<Calendar> | |
{({ Wrapper, Column, Box, Item, headers }) => ( | |
<Wrapper> | |
{headers.map((header, index) => ( |
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
Calendar.defaultProps = { | |
Wrapper: styled.div` | |
display: flex; | |
flex-direction: row; | |
`, | |
Column: styled.div` | |
display: flex; | |
flex-direction: column; | |
margin: 0.5rem; | |
`, |
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 Value | Converted to Number | Converted to String | Converted to Boolean | |
---|---|---|---|---|
false | 0 | false | false | |
true | 1 | true | true | |
0 | 0 | 0 | false | |
1 | 1 | 1 | true | |
0 | 0 | 0 | true | |
000 | 0 | 000 | true | |
1 | 1 | 1 | true | |
NaN | NaN | NaN | false | |
Infinity | Infinity | Infinity | true |
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
function addDays(date = new Date(), days = 0) { | |
const dateClone = new Date(date); // date is an object provided by reference, we need to clone it | |
dateClone.setDate(date.getDate() + days); | |
return dateClone; | |
} | |
const tomorrowDate = (date, days = 1) => addDays(date, days); |
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
function tomorrowDate() { | |
const date = new Date(); | |
date.setDate(date.getDate() + 1); | |
return date; | |
} | |
it("Test tomorrowDate function", () => { | |
expect(tomorrowDate()).toBe(/* ¯\_(ツ)_/¯ - it is imposible to test the function */) |
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
// Custom.scss | |
// Option B: Include parts of Bootstrap | |
// Required | |
@import "node_modules/bootstrap/scss/functions"; | |
// Bootstrap default variables | |
@import "node_modules/bootstrap/scss/variables"; | |
// Your variable overrides | |
@import "./variables"; | |
@import "node_modules/bootstrap/scss/mixins"; |