Posts

Showing posts with the label equality

javascript domElement .is(cssSelector|":visible"|domElement)

  javascript domElement .is( cssSelector|":visible"|domElement ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : return  true  if target element or first element of list is matched with selector other wise  false  . selector :  any css selector string ":visible" :  string for check is visible. Same as isVisible() method DomElement :  matched with element if both are same then return true other wise false. Syntax: DOMElement.is( selector ) DOMNodeList.is( selector ) HTMLCollection.is( selector ) Usase: document.getElementById('firstDiv').is( "div" ) it return true if firstDiv element is div other wise false document.getElementsByTagName('div').is( ".FirstDiv" ) the getElementsByTagName selects all div but is() method check for only first div and if it has class Firstdiv then return true else false. document.getElements...

javascript : Array.contains(Object)

  javascript : Array .contains( Object ) Target: Applicable with  Array  Data Type. Description : Traverse in array and check whether it contains passed  Value/Object  by checking equality. Note: If array contains the passed object/value then return  true  else  false . Syntax: [] .contains( val ) return  true  or  false  depending on whether the array contains passed value. Usase: [1,2,3,4,5].contains(1) It return  true [1,2,3,4,5].contains('1') It return  false ['1',"2",[3,4,5]].contains('1') It return  true ['1',"2",[3,4,5]].contains('2') It return  true ['1',"2",[3,4,5]].contains('3') It return  false ['1',"2",[3,4,5]].contains([3,4,5]) It return  true var arr=[{pName:"keyboard",price:550},{pName:"mouse",price:350},{pName:"ram",price:3500}]; arr.contains({pName:"mouse",price:350}); It return  true var arr=[{pName:"keyboard",price:...

javascript : Object .equals(Object)

  javascript : Object .equals( Object ) Target: Applicable with any javascript  Object  . Description : It compare two javascript object, array, dom element, json object, class object, date object, etc. in depth and compare its property value and return true/false whether both object structure and values are same. It is recursive method so it compare deep in object property. Note: If both object structure is same and holding same property value then it return  true  otherwise  false . Syntax: Object .equals (Object) return  true/false  by comparing values of every property of objects. Usase: var arr1 = [1,2,3,4,5]; var arr2 = [1,2,3,4,5]; arr1.equals(arr2); It return  true . while arr1==arr2 return false var arr1 = [1,2,3,4,5]; var arr2 = arr1.clone(); arr1.equals(arr2); It return  true . while arr1==arr2 return false var arr1 = [1,2,2,4,5]; var arr2 = [1,2,3,4,5]; arr1.equals(arr2); It return  false var d1 = new Date('1/Jan/2020');...