JavaScript Cheat Sheet

Clear an array

array.length = 0

linq.js example

   .where(i => i.prop == test_value)
   .select(i => {"a":i.a_val, "b":i.b_val})
   .distinct(s => s["a"])

jQuery create new element, attach an event, and add it to the list of elements of a parent element

jQuery("<span id='test'>Some text</span>")
   .on("click", function() { alert( + ' clicked') })

jQuery clear contents of an element


URL encode/decode string

encodeURIComponent(string); //to URL econded
unescape(string); //from URL encoded

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s