- var → function scope
- let, const → block scope
function say() {
for (var i = 0; i < 5; i++ ) {
console.log(i)| import React, { useState } from 'react' | |
| const TodoItem = ({ index, name, complete, removeTodo, completeTodo }) => { | |
| return ( | |
| <> | |
| <li style={{ textDecoration: complete ? 'line-through' : '' }}> | |
| {name}{' '} | |
| <span> | |
| {!complete && <button onClick={() => completeTodo(index)}>finish</button>} | |
| </span> |
| const obj = [ | |
| { name: "Joe", age: 17 }, | |
| { name: "Bob", age: 17 }, | |
| { name: "Carl", age: 35 } | |
| ]; | |
| const objRes = [...new Map(obj.map((item) => [item.age, item])).values()]; | |
| const arrRes = [...new Set(obj.map((item) => item.age))] | |
| console.log(objRes); //[{ name: "Bob", age: 17 },{ name: "Carl", age: 35 }] | |
| console.log(arrRes);//[17, 35] |
| let data = { price: 5, quantity: 2 }; | |
| let target = null; | |
| let total = 0; | |
| class Dep { | |
| constructor() { | |
| this.subscribers = []; | |
| } | |
| depend() { | |
| if (target && !this.subscribers.includes(target)) { |
| // 4月から計算一年内のもの | |
| <!-- ・現在の日付が4月以降だったら | |
| →4月から現在の日付カウントする | |
| ・現在の日付が3月以前だったら | |
| →去年の4月から現在の日付までカウントする --> | |
| private function isAnnual($date) | |
| { | |
| $orderTime = $date->format('Y-m-d'); |
| { | |
| "extends": [ | |
| "airbnb", | |
| "plugin:prettier/recommended", | |
| "prettier/react", | |
| "plugin:node/recommended" | |
| ], | |
| "env": { | |
| "browser": true, | |
| "commonjs": true, |
ctrl+b |
prefix | ||
|---|---|---|---|
| basic | session | ||
? |
Show shortcuts | s |
show all sessions |
: |
command mode | d |
Detach from session |
& |
Rename session | ||
| window | pane | ||
c |
create | % |
splite left and right |
| # EditorConfig is awesome: http://EditorConfig.org | |
| # top-most EditorConfig file | |
| root = true | |
| # Unix-style newlines with a newline ending every file | |
| [*] | |
| end_of_line = lf | |
| insert_final_newline = true | |
| trim_trailing_whitespace = true |
| const axios = require('axios').default; | |
| const SlackBot = require('slackbots'); | |
| const URL = 'https://api.ce-cotoha.com/api/dev/nlp/v1/sentiment'; | |
| const COTOHA_TOKEN = process.env.COTOHA_TOKEN; | |
| const SLACK_TOKEN = process.env.SLACK_TOKEN; | |
| const USER_ID = process.env.USER_ID; | |
| axios.defaults.headers.common['Authorization'] = `Bearer ${COTOHA_TOKEN}`; |