Posts

Showing posts with the label check

javascript : Object .isString

  javascript : Object  .isString Target: Applicable with any javascript  Object  Variable  that holds string value . Description : When an object holds an string value then it return  true   otherwise  undefined   . basically it is defined in String prototype. Many time in programming we face a problem that an object variable holds String value or other object structure then it help us. Before writing the code of String manipulation we can check whether a variable holds String value or not. Note: It is an property of String, that is defined in String Prototype. It is useful to check an object variable is String or any other type. another way to check variable holds string value is "typeof(variable) == 'string'" Syntax: ObjectVariable  .isString return  true  when object hold's String value otherwise  undefined Usase: var obj = 'abcd'; console.log('typeof obj = ' + typeof(obj)); if(obj.isString){      co...

javascript : Object.isNaN([nanValue])

  javascript : Object .isNaN( [nanValue] ) Target: Applicable with any javascript  Object  Variable  that holds numeric value . Description : It checks variable value if it is not a numeric value, NaN or infinity then it return  true  otherwise  false . When nanValue is passed as argument then it convert the value in numeric if it's result is  NaN  then return nanValue otherwise converted  Numeric  value. Note: If nanValue is not passed then it return  true/false . If nanValue is passed then it convert value in numeric and return either  Numeric  value or  nanValue . another way to check whether variable holds numeric value or Nan or infinity also convert the string to number if conversion failed then it return argument value  nanValue Syntax: Object .isNaN( [nanValue] ) return  true/false  or converted  Numeric/nanValue Usase: var obj = 55; obj.isNaN() It return  false . var obj = 55/0; ...

javascript : Object.isNodeList

  javascript : Object .isNodeList Target: Applicable with any javascript  Object  Variable  that holds DOM Elements List. Description : When an object holds an html domElementsList/NodeList/htmlCollection then it return  true  otherwise  undefined . basically it is defined in NodeList/htmlCollection prototype. Many time in programming we face a problem that an object variable holds DomElementList or other object structure then it help us. Before writing the code of DomElementList manipulation we can check whether a variable holds domElementsList/NodeList/htmlCollection or not. Note: It is an property of DomElementsList that is defined in NodeList/htmlCollection Prototype. It is useful to check an object variable is DomElementsList or any other type. When we check the typeof(object_variable) it return 'object' not 'NodeList/htmlCollection'. Syntax: Object .isNodeList return  true  when object hold's NodeList/htmlCollection otherwise  unde...

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

  javascript : Object .isNumber Target: Applicable with any javascript  Object/String  Variable  that holds numeric value . Description : When an object holds an numeric value then it return  true  otherwise  undefined . basically it is defined in Number prototype. Many time in programming we face a problem that an object variable holds Numeric value or other object structure then it help us. Before writing the code of Numeric calculation we can check whether a variable holds Numeric value or not. Note: It is an property of Numeric, that is defined in Numeric Prototype. It is useful to check an object variable is Numeric or any other type. another way to check variable holds numeric value is "typeof(variable) = 'number'" but when variable holds string numeric value it return "typeof(variable) = 'string'" Syntax: Object .isNumber return  true  when object hold's Numeric value otherwise  undefined Usase: var obj = 55; console.log('typeof o...

javascript : Object.isArray

  javascript : Object .isArray Target: Applicable with any javascript  Object  Variable  that holds array value . Description : When an object holds an array then it return  true  otherwise  undefined . basically it is defined in array prototype. Many time in programming we face a problem that an object variable holds array value or other object structure then it help us. Before writing the code of array manipulation we can check whether a variable holds array value or not. Note: It is an property of array that is defined in Array Prototype. It is useful to check an object variable is array or any other type. When we check the typeof(object_variable) it return 'object' not 'array'. Syntax: Object .isArray return  true  when object hold's array value otherwise  undefined Usase: var arr = [1,2,3,4,5]; if(arr.isArray){      console.log('Object holds array'); } else{      console.log('Object is not arr...

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