What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?

What It Is This is an arrow function. Arrow functions are a short syntax, introduced by ECMAscript 6, that can be used similarly to the way you would use function expressions. In other words, you can often use them in place of expressions like function (foo) {…}. But they have some important differences. For example, … Read more

What is this weird colon-member (” : “) syntax in the constructor?

Foo(int num): bar(num) This construct is called a Member Initializer List in C++. Simply said, it initializes your member bar to a value num. What is the difference between Initializing and Assignment inside a constructor? Member Initialization: Foo(int num): bar(num) {}; Member Assignment: Foo(int num) { bar = num; } There is a significant difference … Read more

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

The *args and **kwargs is a common idiom to allow arbitrary number of arguments to functions as described in the section more on defining functions in the Python documentation. The *args will give you all function parameters as a tuple: def foo(*args): for a in args: print(a) foo(1) # 1 foo(1,2,3) # 1 # 2 … Read more

var functionName = function() {} vs function functionName() {}

The difference is that functionOne is a function expression and so only defined when that line is reached, whereas functionTwo is a function declaration and is defined as soon as its surrounding function or script is executed (due to hoisting). For example, a function expression: // TypeError: functionOne is not a function functionOne(); var functionOne … Read more

JavaScript property access: dot notation vs. brackets?

(Sourced from here.) Square bracket notation allows the use of characters that can’t be used with dot notation: var foo = myForm.foo[]; // incorrect syntax var foo = myForm[“foo[]”]; // correct syntax including non-ASCII (UTF-8) characters, as in myForm[“ダ”] (more examples). Secondly, square bracket notation is useful when dealing with property names which vary in … Read more

What does

AFAIK >>= is the “same” operation. you can either call i = i << 4; or i <<= 4; It has the same effect. It’s like i = i + 5; and i += 5;