What is lexical scope?

I understand them through examples. 🙂 First, lexical scope (also called static scope), in C-like syntax: Every inner level can access its outer levels. There is another way, called dynamic scope used by the first implementation of Lisp, again in a C-like syntax: Here fun can either access x in dummy1 or dummy2, or any x in any function that call fun with x declared in it. will print 5, will print 10. The … Read more

Tricky : ‘dict’ object is not callable

What you’ve run into is called “shadowing”. You’ve created an object in some namespace (either the global namespace of your module, or the local namespace of a function) that has the same name as a the builtin dict type. This prevents you from accessing the builtin dict in the usual way. You can still get to it, with a bit more … Read more

await is only valid in async function

The error is not refering to myfunction but to start. I use the opportunity of this question to advise you about an known anti pattern using await which is : return await. WRONG CORRECT Also, know that there is a special case where return await is correct and important : (using try/catch)

How can I merge properties of two JavaScript objects dynamically?

ECMAScript 2018 Standard Method You would use object spread: merged is now the union of obj1 and obj2. Properties in obj2 will overwrite those in obj1. Here is also the MDN documentation for this syntax. If you’re using babel you’ll need the babel-plugin-transform-object-rest-spread plugin for it to work. ECMAScript 2015 (ES6) Standard Method Method for ES5 and Earlier Note that this will simply add all attributes of obj2 to obj1 which … Read more

How to create multidimensional array

http://jsfiddle.net/z4Un3/ And if you’re wanting to store DOM elements: Not real sure how useful the above is until you attach the elements. The below may be more what you’re looking for: http://jsfiddle.net/z4Un3/3/ Or, maybe this: Which gives: In the console. If you want to output that to text, you can result.join(‘ ‘);, which would give you 2 … Read more