Here are some examples from this week:
Checking whether a passed argument is an array or a dict:
var a = []
if (Object.prototype.toString.call(a) !== '[object Array]') ...
(perhaps not js itself, but how it is used) Leaking DOM nodes are a thing:
https://developer.chrome.com/devtools/docs/heap-profiling-do...Easy things like getting values of a dictionary:
var d = {
a: [1,2,3,],
b:[4,5]
}
var values = Object.keys(d).map(function(key){
return d[key];
});in Python, it's just .values()
Errors aren't thrown when there are obvious issues with the code.
String.replace replaces one instance instead of all instances in a string.
Functions arguments are a bit of a mess.
differences between
for each (var myVar in myObject)
for (var myVar in myObject)
random things like these:http://stackoverflow.com/questions/2568966/how-do-i-pass-the...
All the things here:
http://www.toptal.com/javascript/10-most-common-javascript-m...
If you import a library, they could have modified the global scope. This is common in JS libraries. Then some things you wrote don't work.
undefined/null thing
differences between var declared function and regular named function.
Many things in the language are not obvious and you have to discover them through trial and error or study JS internals and find out how things are implemented.