Posts
-
Javascript for of vs for in vs for each
Dec 22 2017
If you are new to Javascript (or even a seasoned js developer), you will probably get confused when trying to understand the different types of for loops. So let’s go through the javascript for of vs for in vs for each loop. Standard for loop Suppose we have an array called myArray. Here’s how you would iterate through it using the standard for loop: var myArray = ['Cat','Dog','Horse']; for(let i =0; i< myArray.
-
Subscribe to variable change in Angular 4 Service
Dec 22 2017
If you want to subscribe to variable change in Angular 4 service or Angular 5 service, you can use something called the BehaviorSubject from the rxjs library. A behavior subject is like an observable, except that it must be created with an initial value as it is must always return a value even if the subject hasn’t been updated. A behavior subject will always emit it’s first value as soon as it’s described.
-
Build a Multiplayer game using Javascript
Dec 10 2017
In this tutorial, we will take a look at how to build a multiplayer game using Javascript and NodeJS. My goal is to take you through the basic setup so that you can begin focusing on the actual gameplay. When building a full-scale MMO, there are a lot of things to consider like load balancing, network contingencies, etc. For now, we are going to focus on the bare minimum just to help you get an understanding of how you can creatively and effectively use the available tools of NodeJS to get started.
-
Javascript Hashcash Proof of Work
Dec 04 2017
Suppose that you developed an app that will give users free stuff when they click a button. Obviously, there’s nothing stopping one user from spamming the button one million times and collecting a whole bunch of free stuff. If you wanted to prevent that, you could use something like a CAPTCHA, or perhaps give each user a session and cool off period. You could also implement something called a proof of work system.
-
Build a Javascript Blockchain
Dec 04 2017
Blockchain! It’s the mystical buzzword that every company is saying right now. At its core, the basic concept of blockchain is not hard to understand; it’s essentially a distributed linked list. It’s also used by the popular cryptocurrency called Bitcoin. The advantages of Blockchain is that it allows for a decentralized collection of data whose integrity is easily verifiable, and the data itself is immutable Keep in mind that a fully robust blockchain will also contain smart contracts, mining algorithms (proof of work/proof of stake) and other flavorful elements that you could enhance the chain with.
-
Navigate in ReactJS using React V4 Router
Nov 23 2017
If you are building a large single page application, there might come a time when you will need to add routes to different pages. Unlike traditional routes, adding routes in ReactJS does not trigger a page reload. This makes your SPA extremely fast and feels more like an actual application rather than a simple website. To navigate in ReactJS we will be using the React v4 router.
Setting Up React V4 Router
Begin by installing the React V4 Router from npm:
-
Understanding the JavaScript Spread Operator
Nov 23 2017
There’s a good chance that you have probably come across the Javascript spread operator. If you are unsure, here’s what it looks like: {...} Good luck trying to google search that as you will probably get an empty results page. The Javascript spread operator is a new syntax found in ES6 (ECMAScript2015). The purpose of the spread operator is to allow an iterable like an array or string to be expanded (or spread) across another object or array.
-
Multithreaded Javascript
Oct 22 2017
For the longest time, Javascript has always been implemented using a single thread in your browser. For the most part, this wasn’t a problem. If you’re just using javascript for simple DOM manipulations or form submissions then a single thread is all you need. However, once developers started getting more advanced with their Javascript usage, this eventually led to an issue. Let’s say I have the following single page application (SPA) that shows a list of prime numbers from 1 to 600,000:
-
Machine Learning in Javascript
Oct 15 2017
There’s a good chance that you don’t think of JavaScript when you think of artificial intelligence and machine learning. Instead, you might think of Python and popular libraries like Google’s Tensorflow. While TensorFlow is very powerful and complex, it does require a steep learning curve. Personally, I’m just looking to get my feet wet in some simple AI programming. However, I came across a javascript library called Brain.js. This library makes machine learning in javascript plausible and testable.
-
JavaScript Read USB
Oct 15 2017
You can now officially use JavaScript to read USB devices that are connected to your computer. This is using the new WebUSB API that is still in early draft. As being so, the API could later change or be removed altogether until it receives the final verification. In order to use WebUSB you need to be running the latest version of Google Chrome, with the experimental web platform features flag enabled.
-
Snapchat using Javascript – Zuck.js
Oct 15 2017
Stories! Stories are everywhere these days. Snapchat, Instagram, Facebook, Facebook Messenger and Whatsapp all have stories. Hell, it’s only a matter of time before Microsoft Excel gets a stories update. [][1] In any case, if you want to build an app like Snapchat or build an app like Instagram, there is an easy way to do so. The focus of this tutorial will be about building the story functionality of Snapchat and Instagram into an app.
-
Reddit API Application only OAuth in Javascript
Oct 15 2017
Before you begin developing your Reddit application, you will need to make sure that your app is authorized to access the Reddit API. Authorization is done through OAuth tokens that you receive from the Reddit server. The flow is pretty straightforward: Application Requests Token App Receives Token that’s valid for an hour App makes API calls with given token App request new token when the previous token expires For this tutorial, we are going to build a simple app that grabs the new posts from a subreddit.
-
JavaScript Callbacks
Aug 17 2017
In Javascript, a callback function is a function that is passed into another function as an argument. This allows you to invoke that function with a return value. Remember, Javascript’s implementation within a browser is single threaded (well..until recently at least). That means that all of your code is executed within one linear operation. However, there are some functions in Javascript which are asynchronous. That means that they have the privilege to be invoked anywhere in that line of execution.