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
<template> | |
<component :is="layout"> | |
<slot /> | |
</component> | |
</template> | |
<script> | |
import AppLayoutDefault from './AppLayoutDefault' | |
import { markRaw, watch } from 'vue' | |
import { useRoute } from 'vue-router' |
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 { BaseApi } from '@/api/baseApi' | |
import { FetchApi } from '@/api/fetchApi' | |
import { AxiosApi } from '@/api/axiosApi' | |
export class Api extends BaseApi { | |
private provider: any = new AxiosApi() | |
async fetch(url: string): Promise<any> { | |
return await this.provider.fetch(url) | |
} | |
} |
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
// String methods | |
const str = 'my string' | |
console.log(str.repeat(2)) // Expected output: my stringmy string, | |
console.log(str.startsWith('my')) // Expected output: true | |
console.log(str.startsWith('st')) // Expected output: false | |
console.log(str.startsWith('my', 1)) // Expected output: false | |
console.log(str.endsWith('ing')) // Expected output: true | |
console.log(str.endsWith('st')) // Expected output: false |
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
// lib.js | |
export const PI = Math.PI | |
const sum = (a, b) => a + b | |
export default sum | |
// file.js | |
import sum, { PI } from 'lib.js' | |
console.log(sum(1, PI)) // Expected output: 4.141592654 | |
// lib2.js |
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 fibonacci = { | |
// Iterated objects must implement [Symbol.iterator] method | |
// which returns object with next method | |
[Symbol.iterator]() { | |
let pre = 0, cur = 1 | |
return { | |
next() { | |
[pre, cur] = [cur, pre + cur] | |
return { done: false, value: cur } | |
} |
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
// Default parameters | |
const add = (a, b = 1) => a + b | |
console.log(add(1,5)) // Expected output: 6 | |
console.log(add(1)) // Expected output: 2 | |
// Rest parameters | |
const myFunc = (a, ...rest) => { | |
console.log(rest) | |
} |
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 target = {} | |
// Create proxy with no interceptors | |
const proxy = new Proxy(target, {}) | |
proxy.test = 5 | |
console.log(target.test) // Expected output: 5 | |
console.log(proxy.test) // Expected output: 5 | |
const arr = [1, 2, 3] |
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 symbol1 = Symbol() | |
const symbol2 = Symbol('id') | |
const symbol3 = Symbol('id') | |
// Each symbol is unique | |
console.log(symbol2 !== symbol3) | |
// Symbols could be used as object keys | |
const obj = { | |
[symbol1]: 'War', |
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 promise = (duration = 0) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(resolve, duration) | |
}) | |
} | |
promise(1000) | |
.then(() => { | |
console.log('1 sec') | |
return promise(500) |
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* generateSequence(start, end) { | |
for (let i = start; i <= end; i++) yield i | |
} | |
const sequence1 = generateSequence(1, 10) | |
for (const n of sequence1) { | |
console.log(n) // Expected output: sequence from 1 to 10 | |
} |
NewerOlder