// Hi : I have a function in JS which will return the sizeof an array or a string // it will return 0 for all other data types Lastof = function Lastof ( LastOf, Last ) { // if the LastOf variable is null ? change it to "" LastOf = ( LastOf == null ) ? "" : LastOf // if the Last variable is null ? change it to 0 Last = ( Last || 0 ) // just a buffer to set max limit Buffer = 1000 // check if the character is last or not :- currently not isLast = 0 for ( LastCounter = Last ; LastCounter < Buffer ; LastCounter++ ) { if ( !LastOf [ LastCounter ] ) { isLast = 1 } else { isLast = 0 break } } return ( isLast ) } Sizeof = function Sizeof ( SizeOf ) { // if the SizeOf variable is null ? change it to "" SizeOf = ( SizeOf == null ) ? "" : SizeOf // size of SizeOf Size = 0 // for loop to count size for ( Size = 0 ; Lastof ( SizeOf, Size ) == 0 ; Size++ ) { } return ( Size ) } // it works well in all cases but :::: ( console.log ( Sizeof ( ["","","","1"] ) ) // return 1 // It's not able to count empty values , // how to solve this ?