What’s the difference between “{}” and “[]” while declaring a JavaScript array?

Nobody seems to be explaining the difference between an array and an object. [] is declaring an array. {} is declaring an object. An array has all the features of an object with additional features (you can think of an array like a sub-class of an object) where additional methods and capabilities are added in … Read more

How to use filter, map, and reduce in Python 3

You can read about the changes in What’s New In Python 3.0. You should read it thoroughly when you move from 2.x to 3.x since a lot has been changed. The whole answer here are quotes from the documentation. Views And Iterators Instead Of Lists Some well-known APIs no longer return lists: […] map() and filter() return iterators. If … Read more

What does Java option -Xmx stand for? [duplicate]

see here: Java Tool Doc, it says, -XmxnSpecify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will … Read more

How to use the pass statement

Suppose you are designing a new class with some methods that you don’t want to implement, yet. If you were to leave out the pass, the code wouldn’t run. You would then get an: To summarize, the pass statement does nothing particular, but it can act as a placeholder, as demonstrated here.

Is HTML considered a programming language? [closed]

No, HTML is not a programming language. The “M” stands for “Markup”. Generally, a programming language allows you to describe some sort of process of doing something, whereas HTML is a way of adding context and structure to text. If you’re looking to add more alphabet soup to your CV, don’t classify them at all. … Read more

How can I generate a rainbow circle using HTML5 canvas?

This is not perfect (due to drawing steps …), but it can help you : http://jsfiddle.net/afkLY/2/ HTML: Javascript: The idea is to draw the disc line by line with a hue value corresponding to the line direction. You can change the color base rotation by adding a radius angle to rad variable (adding -pi/2 to rad would make the … Read more

How do I convert a String to an int in Java?

If you look at the Java documentation you’ll notice the “catch” is that this function can throw a NumberFormatException, which of course you have to handle: (This treatment defaults a malformed number to 0, but you can do something else if you like.) Alternatively, you can use an Ints method from the Guava library, which in combination with Java 8’s Optional, makes … Read more