All In One Script
MENU

How do you get a timestamp in JavaScript?

by 4:42:00 AM
undefined
How do you get a timestamp in JavaScript? How can I get a timestamp in JavaScript? Something similar to Unix's timestamp, that is, a single number that represents the current time and date. Either as a number or a string. Answer: Short & Snazzy: + new Date() A unary operator like plus triggers the valueOf method in the Date object and it returns the time-stamp (without any alteration). Details: On almost all current browsers you can use Date.now() to get the UTC timestamp in milliseconds; a notable exception to this is IE8

How can I get query string values in JavaScript?

by 4:40:00 AM
undefined
How can I get query string values in JavaScript? Is there a plugin-less way of retrieving query string values via jQuery (or without)? If so, how? If not, is there a plugin which can do so? answer: 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

For-each over an array in JavaScript?

by 4:38:00 AM
undefined
For-each over an array in JavaScript? How can I loop through all the entries in an array using JavaScript? I thought it was something like this: forEach(instance in theArray) Where theArray is my array, but this seems to be incorrect. Answer: L;DR Don't use for-in unless you use it with safeguards or are at least aware of why it might bite you. Your best bets are usually a for-of loop (ES2015+ only), Array#forEach (spec | MDN) (or its relatives some and such) (ES5+ only), a simple old-fashioned for loop, or for-in with safeguards. But there's lots more to explore, read

Instagram