Skip to main content
deleted 28 characters in body
Source Link
konijn
  • 34.4k
  • 5
  • 71
  • 267

hello everyone iI am a newbie js "developer" and for practice i, I created a super minitiny (8 methods) javascript toolJavaScript library. I need you to give me feedback "should I keep expanding my library or switch to something else" and how todo I improve the code quality of an exist library?

hello everyone i am a newbie js "developer" and for practice i created a super mini (8 methods) javascript tool library. I need you to give me feedback "should I keep expanding my library or switch to something else" and how to improve code quality of an exist library

I am a newbie js "developer" and for practice, I created a tiny (8 methods) JavaScript library. I need you to give me feedback "should I keep expanding my library or switch to something else" and how do I improve the code quality?

Source Link

the mini js tool library

hello everyone i am a newbie js "developer" and for practice i created a super mini (8 methods) javascript tool library. I need you to give me feedback "should I keep expanding my library or switch to something else" and how to improve code quality of an exist library

full code:

function isObject(val) {
      if (val === null) { return false;}
      return ( (typeof val === 'function') || (typeof val === 'object') );
  }
  
function isDate(value) {
      switch (typeof value) {
          case 'number':
              return true;
          case 'string':
              return !isNaN(Date.parse(value));
          case 'object':
              if (value instanceof Date) {
                  return !isNaN(value.getTime());
              }
          default:
              return false;
      }
  }
  
function isEmptyOrOnlySpacesString(str) {
      return (!str || /^\s*$/.test(str));
  }
  
function getTimeZone() {
      return Intl.DateTimeFormat().resolvedOptions().timeZone;
  }
  
function doesObjectHaveEmptyProperties(obj) {
    let emptyKeys = [];
          for(let key in obj) {
          if(obj[key] === "") {
             emptyKeys.push(key + " is empty.\n");
          }
            
      }
    return emptyKeys.join('') + ' others keys are filled';
  }

function isSorted (arr){
  return arr.every((a,b,c) => !b || c[b-1] <= a);
}

function shuffleArray (arr){
  let len = arr.length;
  while (len) {
    const i = Math.floor(Math.random() * len--);
    [arr[len], arr[i]] = [arr[i], arr[len]];
  }
  return arr;
}

function generateRandomIntArr(len, upTo){
  return Array.from({ length: len }, () => Math.floor(Math.random() * upTo));
}

Also you can visit my github repo

thanks in advance