To Compare Float, Double, or Long Data Types

A way to make doubles, floats, or longs ‘equal’.

Float a=1.56148; Float b=1.56139;
  Float threshold = 0.00009 or 0.0001 //difference of Float a and Float b
  if (Math.abs(a-b) <= threshold){//Or < threshold
     //logic here
  }

Continue reading “To Compare Float, Double, or Long Data Types”

Regex basics

function stringSearch(){
    var str="HTML5 javascript CSS JSON?";

    //Define search funciton and outputting the string
    //A spacing is also one of the index in regExp
    document.getElementById("content").innerHTML="search 1: 
    "+str.search('j')+"search 2: "+//If not found, returns -1
 Continue reading "Regex basics"