List Node Packages Installed in Windows

To see a list of node user-installed packages running on Windows, type the command: npm list -g –depth=0 And with package dependencies tree: npm list -g  

localStorage and sessionStorage in JavaScript

In JavaScript, there are 2 ways to store data within a web browser: localStorage, which can be used to save data across browser sessions sessionStorage, which stores data for the page session localStorage localStorage.setItem(‘examplevariable’, ‘123’); var a = localStorage.getItem(“examplevariable”); console.log(a); This prints: To delete a variable, we use: localStorage.removeItem(‘examplevariable’); If we try to access the variable after deleting, it will return null. If we set the item in localStorage and … Continue reading localStorage and sessionStorage in JavaScript

jQuery Introduction and Hello World

jQuery is a popular JavaScript library that is very useful with JavaScript development. It contains many benefits and features, including: It’s cross-browser It has selectors It works with events Ajax support 3rd party plugins from developers To install, go to and select the version you would like to download: If you need support for Internet Explorer versions 6-8, Opera 12.1x, or Safari 5.1x you will need jQuery 1.x. Otherwise, you … Continue reading jQuery Introduction and Hello World

Compare Dates in JavaScript

In JavaScript, there are ways to compare dates as well as methods that will not work. For example, if we have: var date1 = new Date(“2018-01-01 00:00”); var date2 = new Date(“2018-01-01 00:00”); if (date1 == date2) console.log(“equal”) else console.log(“not equal”) This will print: If we print both dates to the console, we will see they are exactly the same (note the date is different from what was supplied – … Continue reading Compare Dates in JavaScript

JavaScript Dates – new Date and UTC

In JavaScript, we can create a new date using: var date1 = new Date(“2018-01-01″); If we print this in the console, we actually get a different date: This is because we are omitting the time, so UTC time is assumed. To display the “correct” date, add the time: var date1 = new Date(“2018-01-01 00:00”); This produces:    

Debugging JavaScript Functions Through Console

In this post we will show how to debug JavaScript through the developer console. We will do this example in Chrome, and it works in similar ways for other browsers. Consider the example where we have an HTML file with an embedded JavaScript function called HelloWorld(): Running this simply produces an alert: Now let’s open the debugger by pressing F12, and put a breakpoint on the code at line 6: … Continue reading Debugging JavaScript Functions Through Console

JavaScript – Scroll to Top

In a scenario where we need to scroll to the top of a web page, we can use JavaScript’s scrollTo. Consider the scenario where there is a page filled with text, and the scroll bar appears. With a scroll button at the bottom: We can add the following code to set the window to it’s x/y coordinates: window.scrollTo(0,0); Full code: When clicking the button, the page will scroll to the … Continue reading JavaScript – Scroll to Top

JavaScript Async / Await

In some previous posts, we looked at using callbacks and promises. In this post, we will look at Await / Async in JavaScript. Await / Async is built on promises, and is a clean way to represent asynchronous processes in a synchronous way. For example, consider the code below. We have 2 functions, DoSomethingAsync and DoSomethingElseAsync.  The first function will complete in 2 seconds, and the second function in 1 second: If … Continue reading JavaScript Async / Await