Posts

Showing posts with the label value

javascript : Array .min

  javascript : Array  .min Target: Applicable with  Array  Data Type. Description : It traverse array and return minimum value. Note: If array is empty then return  undefined  . Syntax: []  .min Usase: [1,2,3,4,5,2,8,3,1].min It return  1 ['z','b','x','a','c'].min It return  'a' Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

javascript : Array .max

  javascript : Array  .max Target: Applicable with  Array  Data Type. Description : It traverse array and return maximum value. Note: If array is empty then return  undefined  . Syntax: []  .max Usase: [1,2,3,4,5,2,8,3,1].max It return  8 ['a','b','x','z','c'].max It return  'z' Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.  Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

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

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

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');...

javascript : DomElement .html(html)

  javascript : DomElement .html( html ) Target: Applicable with any DOM element having attribute innerHTML. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll In case of DOM NodeList first Node Element is processed for get/set. Description : get/set innerHTML of DOM element. if html is passed then it set the innerHTML and return element itself, otherwise return innerHTML of element. Note: after setting the innerHTML of element it return the element itself. Syntax: DOMElement.html( 'html' ) DOMNodeList.html( 'html' ) HTMLCollection.html( 'html' ) Usase: document.getElementById('firstDiv').html("welcome") it sets the innerHTML of div having id firstDiv with html " welcome " and return firstDiv element document.querySelector('#firstDiv').html("welcome") it sets the innerHTML of div having id firstDiv with innerHTML " welcome " and return firstDiv element...

javascript : DomElement .val(value)

  javascript : DomElement .val( value ) Target: Applicable with any DOM input object having attribute value. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll In case of DOM NodeList first Node Element is processed for get/set. Description : get/set value attribute of input element. if value is passed then it set the value and return element itself, otherwise return value of element. Note: after setting the value of input control it return the control itself. Syntax: DOMInputElement.val( 'value' ) DOMInputNodeList.val( 'value' ) HTMLCollection.val( 'value' ) Usase: document.getElementById('txtName').val("Govind Gupta") it sets the value of textbox with value " Govind Gupta " and return textbox element document.querySelector('#txtName').val("Govind Gupta") it sets the value of textbox with value " Govind Gupta " and return textbox element document.get...