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 =…