Posts

Showing posts with the label prototype

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 : 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 : Array.distinct()

  javascript : Array .distinct() Target: Applicable with  Array  Data Type. Description : It remove duplicate items from array and create new array having distinct values/objects. It is an extension method of array object defined in array prototype. Note: logic behind it is create a new array and push only that items which are not contains in array. Syntax: [] .distinct() return new array having unique and distinct values. Usase: [1,2,5,8,4,2,6,3,5,1,3,4,5].distinct() It return new array [1, 2, 5, 8, 4, 6, 3] "Welcome in myjs tutorials".toArray().distinct() It return new array ["W", "e", "l", "c", "o", "m", " ", "i", "n", "y", "j", "s", "t", "u", "r", "a"] "Welcome in myjs tutorials".toCharCodeArray().distinct() It return new array [{"char":"W","code":87},{"char":"...

javascript : String.toCharCodeArray()

  javascript : String .toCharCodeArray() Target: Applicable with  String  Data Type. Description : return array of object {char:character, code:charCode} of string's every characters. Syntax: String .toCharCodeArray() Usase: "Hello World".toCharCodeArray() It return Array [{"char":"H","code":72},{"char":"e","code":101},{"char":"l","code":108},{"char":"l","code":108},{"char":"o","code":111},{"char":" ","code":32},{"char":"W","code":87},{"char":"o","code":111},{"char":"r","code":114},{"char":"l","code":108},{"char":"d","code":100}] Download MYJS.js MyJs is a collection of java script extension methods that enhances the JavaScript objects, class ...

javascript : String.toCodeArray()

  javascript : String .toCodeArray() Target: Applicable with  String  Data Type. Description : return array of character Codes of string's every characters. Syntax: String .toCodeArray() Usase: "Hello World".toCodeArray() It return Array [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100] "MyJs : Make your javascript coding easy.".toCodeArray() It return Array [77, 121, 74, 115, 32, 58, 32, 77, 97, 107, 101, 32, 121, 111, 117, 114, 32, 106, 97, 118, 97, 115, 99, 114, 105, 112, 116, 32, 99, 111, 100, 105, 110, 103, 32, 101, 97, 115, 121, 46] "MyJs : Make your javascript coding easy.".toCodeArray().distinct() It return Array [77, 121, 74, 115, 32, 58, 97, 107, 101, 111, 117, 114, 106, 118, 99, 105, 112, 116, 100, 110, 103, 46] "This library add many dom prototype extension methods to make javascript coding easy.".toCodeArray().forEach(x=>console.log(x)); It return in console 84 104 105 115 32 108 105 98 114 97 114 121 32 97 100 32 109 97 11...

javascript : String.toArray()

  javascript : String .toArray() Target: Applicable with  String  Data Type. Description : It convert string to characters array. Syntax: String .toArray() Usase: "Hello World".toArray() It return Array ["H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d"] "MyJs : Make your javascript coding easy.".toArray() It return Array ["M", "y", "J", "s", " ", ":", " ", "M", "a", "k", "e", " ", "y", "o", "u", "r", " ", "j", "a", "v", "a", "s", "c", "r", "i", "p", "t", " ", "c", "o", "d", "i", "n", "g", " ", "e", ...

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