How to work with JavaScript Drag and drop for touch devices?

Ramu Prasad
Published on 01-Mar-2018 05:51:42
For JavaScript drag and drop for touch devices, you can use jQuery UI Touch Punch or Drag and Drop Touch.A lot of different events are used to successfully perform drag and drop, There are a number of different events to attach to for monitoring the entire drag and drop process −dragstartdragdragenterdragleavedragoverdropdragendTo ... Read More

How to secretly copy to clipboard JavaScript function in Chrome and Firefox?

Ankith Reddy
Published on 01-Mar-2018 05:45:50
To secretly copy JavaScript function to clipboard, use any of the following method: clear() and profile(). These functions work on JavaScript console as well, For clear(),InjectedScriptHost.clearConsoleMessages();For profile(),console.profile.apply(console, arguments)For copy(),InjectedScriptHost.copyText(object);

Is it correct to use JavaScript Array.sort() method for shuffling?

Nikitha N
Published on 01-Mar-2018 05:47:04
Yes, you can use the JavaScript Array.sort() method for shuffling. Let’s see howExamplefunction shuffleDisplay(arr) {    var tmp, current;        // calculating length    var top = arr.length;    if(top) while(--top) {       current = Math.floor(Math.random() * (top + 1));       tmp = ... Read More

Why is [1,2] + [3,4] = “1,23,4” in JavaScript?

Arjun Thakur
Published on 01-Mar-2018 05:43:04
The JavaScript's + operator is used to add two numbers or join two strings. However, use the contact() method to join two arrays to get a new one. For example, [50, 70].concat([90, 100])The above prints, [50, 70, 90, 100]Let’s see your example. The + operator concats strings, and converts the ... Read More

How to display JavaScript variables in an HTML page without document.write?

Sravani S
Published on 01-Mar-2018 05:38:55
Use Element.innerHTML in JavaScript to display JavaScript variables in an HTML page without document.write.You can try to work through the following code snippet −var $myName = document.querySelector('.name'); var $jsValue = document.querySelector('.jsValue'); $myName.addEventListener('input', function(event){    $jsValue.innerHTML = $myName.value; }, false);

How to create SVG graphics using JavaScript?

Govinda Sai
Published on 01-Mar-2018 05:34:23
All modern browsers support SVG and you can easily create it using JavaScript. Google Chrome and Firefox both support SVG.With JavaScript, create a blank SVG document object model (DOM). Using attributes, create a shape like a circle or a rectangle.var mySvg = ""; var myDoc =; var myShape ... Read More

How to convert a binary NodeJS Buffer to JavaScript ArrayBuffer?

Chandu yadav
Published on 01-Mar-2018 05:33:03
Access the buf.buffer property directly to convert a binary NodeJS Buffer to JavaScript ArrayBuffer. The write through the original Buffer instance writes the ArrayBufferView.Keep in mind that the instances of Buffer are also instances of Uint8Array in node.js 4.x and higher versions.ExampleYou can try the following code snippet to convert a ... Read More

How to generate non-repeating random numbers in Python?

Published on 01-Mar-2018 05:54:33
Following program generates 10 random, non-repetitive integers between 1 to 100. It generates a random integer in the given interval and adds it in a list if it is not previously added.>>> import random >>> list=[] >>> for i in range(10):           r=random.randint(1, 100)     ... Read More

How to overload Python comparison operators?

Published on 01-Mar-2018 19:36:22
Python has magic methods to define overloaded behaviour of operators. The comparison operators (<, <=, >, >=, == and !=) can be overloaded by providing definition to __lt__, __le__, __gt__, __ge__, __eq__ and __ne__ magic methods. Following program overloads == and >= operators to compare objects of distance class.class distance:   ... Read More

What is @ operator in Python?

Published on 06-Mar-2018 05:51:14
@ symbol is used to define decorator in Python. Decorators provide a simple syntax for calling higher-order functions. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.we have two different kinds of decorators in Python:Function decoratorsClass ... Read More