Posts

javascript : .one(eventName,eventHandlerFunction)

  javascript : .one( eventName,eventHandlerFunction ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : It register  eventHandlerFunction  only for one time execution with element on triggering of  eventName.  After executing eventHandlerFunction it automatically removed. eventName  : name of event that trigger the event handler function. eventHandlerFunction  : function that register with event and executes when event fired. The [ this ] refer to the object with that eventName is register within the eventHandlerFunction. The [ e ] argument of eventHandlerFunction received the event object of event. Note: It register only one eventHandlerFunction with one event with one element. Syntax: DOMElement.one( eventName, eventHandlerFunction ) DOMNodeList.one( eventName, eventHandlerFunction ) HTMLCollection.one( eventName, eventHandlerFunction ) Us...

javascript : .off(eventName.NameSpace)

  javascript : .off( eventName ) .off( eventName.NameSpace ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : It remove  eventHandlerFunction  with element of  eventName.   It is the reverse of  on()  method. It is the easy way of  removeEventListener  method. eventName  : name of event that was registered with on() method. .NameSpace  : if event is register with NameSpace then for removing eventHandlerFunction NameSpace is used. Note: It clears the eventHandlerFunction from element register with on() method. Syntax: DOMElement.off( eventName ) DOMNodeList.off( eventName ) HTMLCollection.off( eventName ) Usase: document.getElementById('firstDiv').off( "click" ) It remove click eventHandlerFunction from element having id firstDiv. document.getElementsByTagName('div').off( "click" ) it remove click eventHandlerFunction fro...

javascript : .on(eventName,eventHandlerFunction)

  javascript : .on( eventName,eventHandlerFunction ) .on( eventName.NameSpace,eventHandlerFunction ) Target: Applicable with any DOM element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll Description : It register  eventHandlerFunction  with element on triggering of  eventName   . It is the easy way to use of  addEventListener  method. eventName  : name of event that trigger the event handler function. .NameSpace  : optional for registring more than one eventHandlerFunction with an event . eventHandlerFunction  : function that register with event and executes when event fired. The [ this ] refer to the object with that eventName is register within the eventHandlerFunction. The [ e ] argument of eventHandlerFunction received the event object of event. Note: It register only one eventHandlerFunction with one event. If you want to register more than one  eventHandlerFunction...

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", ...