Valid template expressions:
- expressions can reference any property on the passed in context, including nested properties and indexed access to array properties.
{{ name }}
{{ obj.name }}
const canvas = document.querySelector('canvas') | |
const debounce = (func) => { | |
let timer | |
return (event) => { | |
if (timer) { clearTimeout(timer) } | |
timer = setTimeout(func, 100, event) | |
} | |
} |
// SHALLOW COPY | |
const obj1 = { | |
a: 1, | |
b: 2, | |
c: 'three', | |
d: new Date() | |
} | |
const obj2 = { |
// deferred | |
function poll(fn, timeout, interval) { | |
let endTime = Number(new Date()) + (timeout || 2000) | |
interval = interval || 100 | |
let checkCondition = (resolve, reject) => { | |
// If the condition is met, we're done! | |
let result = fn() | |
if (result) { |
// Listener | |
window.addEventListener('storage', handlerEvent) | |
// Whenever we set a localStorage, window object will listen and invoke this handlerEvent function. | |
// We do all validation and stuff to act accordingly. | |
// Handler | |
const handlerEvent = event => { | |
if (event.originalEvent.key != 'message') return |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
elem.clientLeft
, elem.clientTop
, elem.clientWidth
, elem.clientHeight
elem.getClientRects()
, elem.getBoundingClientRect()
<style type="text/css"> | |
.gaye-modal--modal { | |
width: 100%; | |
height: 100%; | |
position: fixed; | |
top: 0; left: 0; | |
z-index: 9999; | |
background-color: rgba(0, 0, 0, 0.5); |
function apiConnect(apiKey) { | |
function get(route) { | |
return fetch(`${route}?key=${apiKey}`) | |
} | |
function post(route, params) { | |
return fetch(route, { | |
method: 'POST', | |
body: JSON.stringify(params), | |
headers: { |
String.prototype.turkishtoEnglish = function () { | |
return this.replace('Ğ','g') | |
.replace('Ü','u') | |
.replace('Ş','s') | |
.replace('I','i') | |
.replace('İ','i') | |
.replace('Ö','o') | |
.replace('Ç','c') | |
.replace('ğ','g') | |
.replace('ü','u') |
import Vue from 'vue' | |
import axios from 'axios' | |
import store from '../store' | |
import { TokenService } from '../services/storage.service' | |
// Full config: https://github.com/axios/axios#request-config | |
let config = { | |
baseURL: | |
process.env.baseURL || |