Skip to content

DannickBedard/utility-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

utility-js

Set object and its child to null

let setAll = (obj, val) => Object.keys(obj).forEach(k => obj[k] = val);
let setNull = obj => setAll(obj, null);
setNull(this.inspectionDetail);

Delete HTML tag in string

const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');

Format a number to a string with comma

function numberToStringWithComma(number) {
    // convert number to string
    let str = String(number);
    
    let s = '';
    let count = 0;
    for (let i = str.length - 1; i >= 0; i--) {
      s = str[i] + s
      count++
      // add a comma to every three numbers
      if (count % 3 == 0 && i != 0) {
        s = ',' + s
      }
    }
    return s
}

Easy access for routing

https://gist.github.com/branneman/8048520

<script src="https://gist.github.com/branneman/8048520.js"></script>

Get timezone

console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published