What is the difference between call and apply? The difference is that apply lets you invoke the function with arguments as an array; call requires the parameters be listed explicitly. A useful mnemonic is "A for array and C for comma." See MDN's documentation on apply and call . Pseudo syntax: theFunction.apply(valueForThis, arrayOfArgs) theFunction.call(valueForThis, arg1, arg2, ...) Sample code: function theFunction ( name , profession ) { alert ( "My name is " + name + " and I am a " + profession + "." ); } theFunction ( "John" , "fireman" ); theFunction . apply ( undefined , [ "Susan" , "school teacher" ]); theFunction . call ( undefined , "Claude" , "mathematician" ); Map vs Object in JavaScript According to mozilla: A Map object can iterate its elements in insertion order - a for..of loop will return an array of [key, v...
I write in my blog all those contents which I find interesting and amazing.