Posts

Showing posts with the label true

javascript : Object.isDomElement

  javascript : Object .isDomElement Target: Applicable with any javascript  Object  Variable  that holds DOM Element . Description : When an object holds an html domElement then it return  true  otherwise  undefined . basically it is defined in DomElement prototype. Many time in programming we face a problem that an object variable holds DomElement or other object structure then it help us. Before writing the code of DomElement manipulation we can check whether a variable holds DomElement or not. Note: It is an property of DomElement that is defined in DomElement Prototype. It is useful to check an object variable is DomElement or any other type. When we check the typeof(object_variable) it return 'object' not 'DomElement/Node'. Syntax: Object .isDomElement return  true  when object hold's DomElement otherwise  undefined Usase: var obj = document.querySelector('div') if(obj.isDomElement){      console.log('Object hold...

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:...