Loading...
More JavaScript Posts
let nums = [1,2,3,1]var containsDuplicate = function(nums) {let obj = {};for(let i =0; i< nums.length; i++){if(obj[nums[i]]){obj[nums[i]] += 1;return true;}else{obj[nums[i]] = 1;}}return false;};console.log(containsDuplicate(nums));
const ResponsiveCardImg = styled(Card.Img)`// For screens wider than 768px@media(min-width: 768px) {// Your responsive styles here.}// For screens smaller than 768px@media(max-width: 768px) {// Your responsive styles here.}`export default function App() {return (<MainContainer><Container><Card text='white' bg='dark' style={styles.mainCard}><ResponsiveCardImgstyle={styles.cardImage}onClick={handleClick}src={apeImage}alt='Degenerate Ape Academy'/><Card.Body><Card.Title className='text-center' as='h2'>{apeId}</Card.Title></Card.Body></Card></Container></MainContainer>);}
function spam(times = 1,log = true){for(let i = 0; i < times; i++){$.get("backend-search.php", {term: (" "+Date.now())}).done(function(data){if(log) console.log(data);});}}spam(100000);
const formatDuration = ms => {if (ms < 0) ms = -ms;const time = {day: Math.floor(ms / 86400000),hour: Math.floor(ms / 3600000) % 24,minute: Math.floor(ms / 60000) % 60,second: Math.floor(ms / 1000) % 60,millisecond: Math.floor(ms) % 1000};return Object.entries(time).filter(val => val[1] !== 0).map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`).join(', ');};formatDuration(1001); // '1 second, 1 millisecond'formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds'
import { configureStore } from "@reduxjs/toolkit";import { combineReducers } from "redux";import profile from "./profile";import auth from "./auth";import alert from "./alert";const reducer = combineReducers({profile,auth,alert,});const store = configureStore({ reducer });export default store;
const copyToClipboard = str => {const el = document.createElement('textarea');el.value = str;el.setAttribute('readonly', '');el.style.position = 'absolute';el.style.left = '-9999px';document.body.appendChild(el);const selected =document.getSelection().rangeCount > 0? document.getSelection().getRangeAt(0): false;el.select();document.execCommand('copy');document.body.removeChild(el);if (selected) {document.getSelection().removeAllRanges();document.getSelection().addRange(selected);}};copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard.