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...
I have some functions which occasionally (not always) will receive a callback and run it. Is checking if the callback is defined/function a good style or is there a better way?  Example:  function save (callback){    .....do stuff......    if(typeof...
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'm new-ish to JavaScript.  I understand many of the concepts of the language, I've been reading up on the prototype inheritance model, and I'm whetting my whistle with more and more interactive front-end stuff.  It's an interesting l...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.