JS - Other

Check If Day Is A Weekday

isWeekDay = (date) => date.getDay() % 6 != 00;

Check Number Is Even Or Odd

isEven = (num) => num % 2 === 0;

Check the jQuery version using Console command

console.log(jQuery().jquery);

Clipboard API

The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste), as well as to asynchronously read from and write to the system clipboard.


navigator.clipboard
  .readText()
  .then(
    (clipText) => (document.querySelector(".editor").innerText += clipText),
  );

Clipboard Copy

navigator.clipboard.writeText(string)

Cloning Arrays

array2 = [...array1]

Convert Any Value to Boolean

!!value

Convert Fahrenheit / Celsius

celsiusToFahrenheit = (celsius) => celsius * 9/5 + 32;
fahrenheitToCelsius = (fahrenheit) => (fahrenheit - 32) * 9/5;

Convert Number To Array

var myArr = String(num).split("").map((num)=>{
 return Number(num)
})

Convert Number To String

var string = number + '';

Convert String To Number

var number = +string

Count Number of Repeat Value in Array

arr.reduce((a, c) => (a[c] = (a[c] || 0) + 1, a), Object.create(null));