Javascript’s call, apply and bind methods

Javascrip's apply, call and bind methods

I’ve been mulling over getting this post up for a while now – simply because functions are a big deal in Javascript. Javascript functions are packed with so many properties, methods and it’s fundamental nature requires some quality time in understanding its features.

There are a few things to keep in mind when dealing with Javascripts call(), apply, and bind methods()

  • call(), apply() and bind() are three methods every function has access too
  • bind() creates a copy of the function object in question
  • call(), apply() and bind() methods are methods that allow an object to point to a different ‘this’ variable when invoked.
  • Common patterns used in conjunction with call(), apply() and bind() are function borrowing and function currying.

Continue reading “Javascript’s call, apply and bind methods”

Importing sql database using the command line

Importing sql database using the command line

This is definitely worth a post. Just when I want to disregard this utility as trivial – every now and then I get a consulting gig where I need to run a full backup – yes of everything, files, database, the works. You see, sometimes I get a task that isn’t as black and white as it may seem at first glance – something is a bit unconventional, but you know – there is nothing wrong with that. Sites come in all shapes and sizes, in all sorts of architectures. It’s good to get exposed to a variety even really weird ones. Look I’d rather poke around a dev site over production no matter how tempting it is – I’ve seen way too many sites go down in my life time, it’s not worth the gamble. I tell every junior developer – the first thing you should do is create a back up. First thing you should do. Then you can show off your programming skills later and you know – be that “rockstar” developer you were meant to be.

Continue reading “Importing sql database using the command line”

Javascript’s defer vs async attribute

Javascript’s defer vs async attribute

Flashbacks of vanilla javascript cloud my mind – back when we didn’t have Jquery. All we had was Javascripts’ event listener method to detect whether the entire DOM was loaded before scripts were fired off.

Why was this necessary though? Well, if you’re a developer you very well know – page speed. And back in those days, programmers weren’t so mindful of placing external javascript files – the head section, footer and I’ve seen some sprinkled throughout the body. Not optimal at all – this can have huge negative implications in terms of functionality and speed.

Continue reading “Javascript’s defer vs async attribute”

Fixing a network 404 error using typeof

Fixing a network 404 error using typeof

Javascript’s typeof operator is an essential debugging tool that many young programmers often miss. Countless times I’ve run into situations where my program wasn’t working because either my variable was unnoticeably coerced or I was just completely unaware of a data type. As mentioned in a previous post – a season programmer should know their data types! Another thing a seasoned programmer ought to know is to prevent themselves from being too arrogant – yes, we need help and using the “typeof” operator is there to the rescue.

Continue reading “Fixing a network 404 error using typeof”