How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves? ANSWER JavaScript Closures for Beginners Submitted by Morris on Tue, 2006-02-21 10:19. Community-edited since. Closures Are Not Magic This page explains closures so that a […]

To get query string in javascript You don’t need jQuery for that purpose. You can use just some pure JavaScript: function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, “\\$&”); var regex = new RegExp(“[?&]” + name + “(=([^&#]*)|&|#|$)”), results = regex.exec(url); if (!results) return null; if (!results[2]) return ”; return decodeURIComponent(results[2].replace(/\+/g, […]

How can I access the correct object? ANSWER: What you should know about this this (aka “the context”) is a special keyword inside each function and its value only depends on how the function was called, not how/when/where it was defined. It is not affected by lexical scope, like other variables. Here are some examples: function foo() { console.log(this); […]

I have a situation where I’m trying to use grunt to lint a codebase, excluding specific folders. My question is, what is the best way to to exclude folder in grunt? grunt uses minimatch (similar to bsdglob) under the hood to match files, but I can’t seem to figure out how to do a .gitignore […]

How link like this: <a href=”/” onclick=”,’targetWindow’,’toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,’) could be openned in a new window in a specific size. How can I specify the height and width? ANSWER: The simples solution for this question is something like this <a href=”/” onclick=”,’targetWindow’, ‘toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=SomeSize, height=SomeSize’); return false;”>Popup link</a> Where width and height […]

I have a SELECT and I want to convert int to float. How to convert it?   ANSWER The easiest way to convert int into float is to use CAST function: CAST(1 as float) or try casting to NUMERIC CAST(1 AS NUMERIC(10,4)) or do the simple trick: 1 + 0.0 or 1 / 1.0 this should work as […]