Last active
February 17, 2020 10:35
-
-
Save kirandash/cc9d92e386f51fdbf8f3886e4237bea5 to your computer and use it in GitHub Desktop.
JavaScript Short Cuts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Remove Duplicate Objects from array | |
data = [{block:'234'......},{},{}] | |
data = _.uniqBy(data, function(v){ | |
return v.block + ' ' + v.street_name + ' ' + v.floor_area_sqm + ' ' + v.resale_price + ' ' + v.month + ' ' + v.lease_commence_date + ' ' + v.flat_type; | |
}); | |
// 2. Check whether an input string contains a number in javascript | |
function hasNumber(myString) { | |
return /\d/.test(myString); | |
} | |
// 3. Share Via WhatsApp | |
<a href="whatsapp://send?text=Please sign up using this link: https://trubid.sg/signup/?ref=9N3RD43" data-action="share/whatsapp/share">Share via Whatsapp</a> | |
// 4. Check if empty object | |
return (Object.keys(auction).length === 0 && auction.constructor === Object) ? true : false; | |
// 5. Convert UL LI to array | |
description = obj.description.replace(/<ul>|<\/ul>|<\/li>/g, ""); | |
description = description.split('<li>'); | |
description.shift(); // Removes 1st element of array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment