Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

KenjiMorita kenmori

🏠
Working from home
View GitHub Profile
@kenmori
kenmori / file0.js
Last active Jul 3, 2016
Angular#serviceと#factoryの違い。どういう時どっちを利用するか。定義方法。使い方を理解するまとめ(2015/8/29更新) ref: http://qiita.com/M-ISO/items/102c6daf192187d5a161
View file0.js
//ex1 //値返す書き方
var myApp = angular.module('MyApp',[]);
myApp.factory('myUrlFactory',function myUrlFunc(){
return 'https://github.com/kenjimorita/';
})
//ex2 //関数を返す書き方
var myApp = angular.module('MyApp',[]);
myApp.factory('myFunc',function($window){
return{
@kenmori
kenmori / file0.txt
Last active Aug 29, 2015
脱TS近眼!!Typescriptと仲良くなってみる(1日目) ref: http://qiita.com/M-ISO/items/d4206b506e63da98a1e4
View file0.txt
module moritaA{
export interface Imorita {//(1)
get: Function;
num1: number;
num2: number;
}
export class Aclass implements Imorita{
public num1:number = 1
public num2:number = 4
constructor(){
@kenmori
kenmori / file0.txt
Last active Aug 29, 2015
TypeScriptでConstructor外で関数を宣言型か無名関数を代入するかでの実行比較 ref: http://qiita.com/M-ISO/items/4401c2ff1c34f4f87156
View file0.txt
module A{
interface ImoritaA{
name:string;
}
class Aclass implements ImoritaA{
constructor(public name){
this.name = "fafa"
}
public func1= ()=>{//constructor外、無名関数を代入
}
@kenmori
kenmori / js
Last active Mar 19, 2017
【TypeScript】super()の使い方理解する。(親Classのメソッドを使用、値を渡す) ref: http://qiita.com/M-ISO/items/bed1be20c8eaab1c7762
View js
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Person = (function () {
function Person(name) {
this.name = name;
}
@kenmori
kenmori / ES6
Last active Sep 2, 2015
ES6マラソン・1 〜BabelでES6(Class,let,const,DefaultParameter,Destructuring)がどのようにトランスパイルされるか試して理解する〜 ref: http://qiita.com/M-ISO/items/b3da7913ca0f2140201e
View ES6
//ex1 babel
function today() { return { d: 6, m: 2, y: 2013 }; }
var { m: month, y: year } = today(); // month = 2, year = 2013
//ex1 after
"use strict";
function today() {
return { d: 6, m: 2, y: 2013 };
}
var _today = today();//関数名が「_変数」になっている
@kenmori
kenmori / file0.js
Last active Jul 14, 2018
ESLintのエラールール。日本語ざっくり解説[ベストプラクティス編] ref: https://qiita.com/M-ISO/items/4cd183e2496c2937a53e
View file0.js
// Bad
var o = {
set a(value) {
this.val = value;
}
};
// Good
var o = {
set a(value) {
@kenmori
kenmori / file0.js
Last active Jul 14, 2018
ESLintのエラールール。日本語ざっくり解説[スタイル編] ref: https://qiita.com/M-ISO/items/113ddd448bdc496af783
View file0.js
/*eslint array-bracket-spacing: [2, "never"]*/
var arr = [ 'foo', 'bar' ]; /*error There should be no space after '['*/ /*error There should be no space before ']'*/
var arr = ['foo', 'bar' ]; /*error There should be no space before ']'*/
var arr = [ ['foo'], 'bar']; /*error There should be no space after '['*/
var arr = [[ 'foo' ], 'bar']; /*error There should be no space after '['*/ /*error There should be no space before ']'*/
var arr = ['foo',
'bar'
];
var [ x, y ] = z; /*error There should be no space after '['*/ /*error There should be no space before ']'*/
var [ x,y ] = z; /*error There should be no space after '['*/ /*error There should be no space before ']'*/
@kenmori
kenmori / JavaScript.md
Last active Jun 21, 2021
JavaScript練習問題集(ECMAScript2015,2016,2017,2018,2019,2020,other Library)
View JavaScript.md

JavaScript練習問題集

JavaScript

更新情報

・Decoratorsに関する問題を追加(2020/6/6)
・リンクを追加(2020/5/30)
・問題を追加(2020/4/18)
@kenmori
kenmori / JavaScript練習問題ブログ用.md
Last active Nov 28, 2020
JavaScript練習問題ブログ用
View JavaScript練習問題ブログ用.md

問1

const a = {a: 'a'}const b = {b: 'b'} をマージしたc を出力してください e.g{a:'a',b:'b'}

const a = {a: 'a'};
@kenmori
kenmori / immutableJS_Map.js
Last active Dec 27, 2016
【Immutable.jsの使い方】Immutable.js超入門~ReactでsetStateのプロパティ値に直接代入避ける~
View immutableJS_Map.js
//mapを作成
var map1 = Immutable.Map({
a: 1,
b:2,
c: 3
});]
//新しい配列やMapを返すところ。不変なオブジェクトを返す