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 React, { Component } from 'react' | |
import { Card, Flex } from 'antd-mobile' | |
import { Text, View, StyleSheet, Image } from 'react-native' | |
import * as routePaths from '../routes/web/routeConstants' | |
import order from '../images/odrMdcn@2x.png' | |
import reOrder from '../images/rflMdcn@2x.png' |
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
window.addEventListener('mousemove', debounce(eventHandler, 2000)); | |
function debounce (cb, wait) { | |
var timeoutID | |
return function (...args) { | |
clearTimeout(timeoutID) | |
timeoutID = setTimeout(() => cb.apply(this, args), wait) | |
} | |
} |
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
var movieLists = [{ | |
name: "New Releases", | |
videos: [{ | |
"id": 70111470, | |
"title": "Die Hard", | |
"rating": 4.0 | |
}, { | |
"id": 654356453, | |
"title": "Bad Boys", | |
"rating": 5.0 |
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
var arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 7, 8, 7, 1, 2, 3] | |
var finalArr = [] | |
arr.forEach(function (element, index) { | |
if(arr.indexOf(element, index + 1) > -1) { | |
finalArr.push(element) | |
} | |
}) |
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 timer(interval) { | |
setTimeout(function() { | |
console.log('hello') | |
timer(interval) | |
}, interval) | |
} | |
timer(2000) |
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 foo () { | |
var bar = 'bar' | |
function baz () { | |
console.log(bar) | |
} | |
bam(baz) | |
} |
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
var str = 'the quick brown fox jumps then quickly blow air' | |
var arr = [] | |
for(let i=0; i<=str.length; i++) { | |
if (arr[str[i]]) { | |
arr[str[i]]++ | |
} else { | |
arr[str[i]] = 1 | |
} |
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
var person = function (firstName, age) { | |
this.name = firstName | |
this.age = age | |
} | |
person.prototype.getInfo = function () { | |
console.log(this.name + ' is ' + this.age + ' years old!') | |
} | |
var employee = function (firstName, age, salary) { |
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 deepClone(object){ | |
var newObject = {}; | |
for(var key in object){ | |
if(typeof object[key] === 'object'){ | |
newObject[key] = deepClone(object[key]); | |
}else{ | |
newObject[key] = object[key]; | |
} | |
} | |
return newObject; |
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 candies(n, arr) { | |
var ans = 0 | |
var values = [] | |
values[0] = 1 | |
for (let i=1; i< n; i++) { | |
if (arr[i-1] < arr[i]) { | |
values[i] = values[i-1] +1 | |
} else { | |
values[i] = 1 | |
} |
OlderNewer