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
// Original data | |
{ | |
"data": { | |
"level1": { | |
"field1": "data 1 on level 1", // changed | |
"level2": { | |
"field1": "data 1 on level 2", | |
"level3": { | |
"field1": "data 1 on level 3", //changed | |
"field2": "data 2 on level 3" |
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
<template> | |
<div> | |
<form @submit.prevent="addUser"> | |
<input type="text" v-model="form.name" /> | |
<button type="submit">Add user</button> | |
</form> | |
<ul> | |
<li :key="user.id" v-for="user in users">{{user.name}}</li> | |
</ul> | |
</div> |
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 store = { | |
namespaced: true, | |
state: { | |
users: [], | |
posts: [] | |
}, | |
mutations: { | |
set(state, { name, data }) { | |
state[name] = data; | |
}, |
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 obj1 = { | |
field: { | |
key: "foo" | |
} | |
}; | |
const obj2 = { | |
field: obj1.field | |
} |
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 calcSum = list => list.reduce((acc, val) => acc + val, 0); | |
const cumulativeSum = (list, acc = []) => { | |
if (!list.length) return acc; | |
const sum = calcSum(list), | |
subset = list.slice(0, list.length - 1); | |
return cumulativeSum(subset, [sum, ...acc]); |
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 operation = a => b => c => a * b + c; | |
operation('2')(3)('4') |
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 { log } = console; | |
const foo = word => { | |
const bar = word => setTimeout(() => log(word), word.length) | |
bar(word); | |
return bar; | |
} |
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
spread(value) { | |
return (Math.random() - 0.5) * value * 2 | |
}, | |
transformGeneratePersonObjects(){ | |
// we could do something much smarter with object layout, but let's keep it simple | |
const { x, y } = this.baseObject.position; | |
// iterate over our Shareholders array | |
this.shareholders.forEach(shareholder => { | |
const position = { |
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
// api.js | |
export const GetAllProjects = () => Vue.http.get('/swage/v1/projects') | |
// resources/Project.js | |
import Vue from 'vue'; | |
export default Vue.resource( | |
"swage/v1/projects{/id}", |
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
// api.js | |
export const GetAllProjects = () => Vue.http.get('/swage/v1/projects') | |
// resources/Project.js | |
import Vue from 'vue'; | |
export default Vue.resource( | |
"v1/projects{/id}", |
NewerOlder