miscellaneous

Javascript Call Apply and Bind

Javascript call method example var john = { name:’John’, age:28, presentatoin:function(style,timeOfDay){ if(style == ‘formal’){ console.log(this.name + this.age + timeOfDay) } if(style == ‘friendly’){ console.log(this.name + this.age + timeOfDay) } } } john.presentatoin(‘formal’,’Goodmorning’) var emily = { name:’Emily’, age:23, } john.presentatoin.call(emily,’friendly’,’Evening’)…

Bookmark Application with JavaScript

How to create bookmark web application with pure JavaScript. document.getElementById(‘myForm’).addEventListener(‘submit’,addBookmark); function addBookmark(e){ var siteName = document.getElementById(‘siteName’).value; var siteUrl = document.getElementById(‘siteUrl’).value; var bookmark = { name:siteName, url:siteUrl } if(localStorage.getItem(‘bookmarks’) === null){ var bookmarks = []; bookmarks.push(bookmark); localStorage.setItem(‘bookmarks’,JSON.stringify(bookmarks)) } else{ bookmarks =…

How to fetch feed from YouTube API

Put this script in head of the page <script type=”text/javascript”> function showMyVideos(data){ var output =”; for(var i=0;i < data.feed.entry.length; i++){ var title = data.feed.entry[i].title.$t; var thumbnail = data.feed.entry[i].media$group.media$thumbnail[0].url; var id = data.feed.entry[i].id.$t.substring(38); output += ‘<h3>’ + title + ‘</h3>’; output…