I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I could convert it into JavaScript and run eval() on it to yield the result.  However, I've always shied away f...
Google JavaScript Style Guide advises against extending the Array.prototype. However, I used Array.prototype.filter = Array.prototype.filter || function(...) {...} as a way to have it (and similar methods) in browsers where they do not exist. MDN a...
I've recently read the Yahoo manifesto Best Practices for Speeding Up Your Web Site. They recommend to put the JavaScript inclusion at the bottom of the HTML code when we can.  But where exactly and when?  Should we put it before closing </h...
At work, we place braces on the next line, but at home, I do the opposite. Which one do you prefer? (K&R vs OTBS)  function something() {     // ... }  function something() {     // ... }   A lot of JavaScript libraries seem to use the OTBS (one...
I want to toggle a variable between 0 and 1. If it's 0 I want to set it to 1, else if it's 1 I want to set it to 0.  This is such a fundamental operation that I write so often I'd like to investigate the shortest, clearest possible way o...
Which one of these two ways is faster and why?  window.setTimeout("func()", 100);   Or  window.setTimeout(function(){func();}, 100);   I'm guessing the second way is faster if for no other reason other than John Resig and all the ninjas u...
Can any body throw me some arguments for using inline functions against passing predefined function name to some handler.   I.e. which is better:  (function() {   setTimeout(function() { /*some code here*/ }, 5); })();   versus  (function() {   funct...
There are known Style Attribute XSS attacks like:  <DIV STYLE="width: expression(alert('XSS'));">   Or  <DIV STYLE="background-image: url(javascript:alert('XSS'))">   All the examples I've seen use eith...
I have a function that takes a data from server:  function getData(data){     console.log(data.someVar); }   Webstorm says that someVar - is an unresolved variable. What can I get rid of such warnings?   I see several options:   Suppress warnings in...
I've got the first file in my code directory as follows  myNamespace.js  var myNamespace = {};   Then my subsequent files can look as one of the two following ways.  first  (function (ns) {     ns.DoStuff = function(){         // do stuff     } }...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.