21 Jan 2020

JavaScript? Ew!


“You can access the article after the ad.”

Many people have encountered similar situations like that. You are just casually browsing the web and then an unskippable ad appears right before you. Now you have to sit there and watch the timer tick down to 0 before you can regain site control. No one likes to visit a site bloated with ads. However, ads are there to keep the website running and free for the public. But then, there are also those sneaky ads that dress themselves to be the next page button. To direct you to “Critical alert from Microsoft.”

This is partially why some people detest JavaScript, it allowed the birth of web pages filled with ads that slows down connection and ruin the browsing experience. But one should not forget that JavaScript also allowed the birth of many beautiful modern web UIs and in fact vital for some websites.

I too avoided JavaScript like a plague as I don’t have much reason to use it, but ICS 314 finally gave me the push to try it out. It felt similar yet strange at the same time. Like Python, JavaScript doesn’t require you speicify variable before assignment or specifying the return type for a function or a method unlike Java, and C/C++.

Python:

def myFunction():
	return 10
	
ret = myFunction()
print(ret) # 10

JavaScript:

function myFunction() {
	return 10;
}

const ret = myFunction();
console.log(ret); // 10

But unlike the languages I know, JavaScript gives you the ability to return a function and assign it to a variable.

function multiply(input) {
	return function(second) {
		return input * second;
	}
}

const ret = multiply(2);
console.log(ret(3)); // 6

From my short time interacting with JavaScript, it definitely feels like a a powerful tool for those don’t want to be limited by HTML and CSS. With more and more companies moving to web applications, JavaScript is here to stay for a quite some time.

If you want to get into JavaScript, FreeCodeCamp offers a great introductory lesson, and maybe try to work through some timed examples from WODs to help you get more familiar with the language.