Skip to content

Instantly share code, notes, and snippets.

@DorukUlucay
Last active September 7, 2018 10:41
Show Gist options
  • Save DorukUlucay/a297091de630fdbf3946e93f22a96ec6 to your computer and use it in GitHub Desktop.
Save DorukUlucay/a297091de630fdbf3946e93f22a96ec6 to your computer and use it in GitHub Desktop.
some helpful javascript snippets

Some helpful Javascript Snippets. Click on it to see all.

Bazı faydalı Javascript kod parçacıkları. Hepsini görmek için tıklayın.

function getMonthName(monthNum) {
var monthNames = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
if (monthNum == null) {
var d = new Date();
return monthNames[d.getMonth()];
} else {
return monthNames[monthNum - 1];
}
}
function getRandomInt(min, max){
if(min == undefined|| min == null) min = 0;
if(max == undefined|| max == null) max = 1000000;
return Math.floor(Math.random() * (max - min + 1) + min);
}
String.prototype.contains = function(substr) {
if (this.indexOf(substr) === -1) {
return false;
} else {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment