Sitemap
Daliska F. Royan

Daliska F. Royan

Human tends to assume something they don’t familiar with, so let’s get to know each other!

Javascript for React Developer

5 min readJul 19, 2020

--

Press enter or click to view image in full size

Well, React has taken the world by storm since it’s appearance as a progressive Front-end Javascript Framework. At this very first chance in Medium, I’d like to share about some of my experience about attending Indonesian online bootcamp of React. Thanks to Sanbersy Company who generous enough to establishing this online bootcamp, The most lovable thing was the interactivity between mentor and students are so positive. It didn’t feels like i’m going to stranded anytime I came across difficulties.

Anyway, I’m not going through all of my experience there, but I only distilled some information that I might need to came back and polish, rather than explaining in details about how I learn React because the secret is, It’s better to grind in fundamental level before dipping into a concept.

I’ll group all of the material in a day frame to get it easy to recall, So let’s jump right in!

1st Day — Monday

👉 The caveat of var, let, and const

I’m not going to point out the history and i’ll jump straight to the explanation which cover the quirk of these variable. Starting from the oldest one, var that have function scoped main characteristic, means it could only lives within a function. On the other hand, could be globally scoped if it declared outside a function.

But the thing is, we could also have access to overwrite var in from any function or loop within global scope for unlimited times and you won’t get error out of it. Simple as that. But, this simplicity comes at a price. When you write tons of code, you won’t know which or what happened about each of your every variable that globally scoped which is dangerous as it would lead to bug and inconsistency inside your codebase.

it’s not recommended to modify a variable outside the scope of which those variables were created

Here let and const come in handy! They introduce us a new scope called block scope. This referred to scope that lives between curly brackets code. Any modifying are only happen on the scope, otherwise you would get an error.

let variable could block bad behavior from var variable

the main difference between const and let are their modifiability. it’s possible to re-assign let, but not to re-declared. whereas const cannot be modified.

comparison about re-assignment and re-declaration in let

The thing that need to underline is, when assigning const to an object, someone could modify it’s object’s property but not with object itself.

modifying object properties in const variable

2nd Day — Tuesday

👉 Hoisting

Along the way, I stumbled upon this Javascript concept called Hoisting, which the mechanism of putting variable declaration on top of the code’s scope before being executed.

👉 `this` keywords

this keywords must be familiar for some of you who have learned Class oriented language before. In javascript, this keywords actually refers to the object from which it has been executed.

By default, the execution context of this keywords are Global Object. Try to tinker with your browser’s console and type this. It would return Window object which in this case are the Global Object of your browser.

👉 arrow functions

The next is the concept of arrow function, which doesn’t only act as syntactic sugar for function declaration syntax but also comes with some particular traits.

explicit & implicit returns

Surprisingly here, Javascript gave us options to whether we want to declare the return statement in the function. We could use curly bracket to explicitly write return keyword whereas we could just omit it if we don’t want to.

explicit returns are particularly useful when you had a long list of logic inside an arrow function

the scope of arrow functions

Get Daliska F. Royan’s stories in your inbox

Join Medium for free to get updates from this writer.

when arrow functions are being nested in another functions, the this keywords would have scope on where it was declared in. Yeah, I know, that’s a superficial statement. I’d like very much to write in depth about it, but it’s a whole another story, too much that I planned to make different sections out of it. Anyway, bare with me for right now.

👉 declaring an object — part 1

object literal syntax

this is the most popular way to create an object. All we have to do is just declaring a variable and assign it to an object. Where when we declare a method, we expect to explicitly returning the value. That’s understandable because it may contains several statement. So it’s only utilizing regular function instead of arrow function.

or using a shorthand syntax by dropping off the colon

object constructor

Creating through this method are resembling OOP based language like Java and C++, as it also native in Javascript at the first place. First off create and constructor function and used in conjunction with new keywords to initialize new objects based on constructor we have made. It’s mandatory to use regular function when declaring constructor

3rd Day — Wednesday

👉 spread syntax

... syntax could works as spread operator or rest parameter. The spread operator representing the value of an array, so that it could be manipulated into another array. The common use cases are concatenating a bunch of array.

spread syntax acted as spread operator

the rest parameter accumulate all of the parameter without deciding the quantity of how much arguments the function would take .

rest parameters as arguments accumulator

👉 destructuring objects

It used for assigning new variable based on object values we’re destructured from. If used properly, It could drastically cutting off the amount of code but nevertheless doesn’t affect the readibility. Charming indeed!

4th Day — Wednesday

👉 declaring an object — part 2

class method

“we’re already have a lot of method about declaring an object, why’d we should care about this?”. Well actually, in terms of modeling data’s entity, the method above are not really efficient in the long run

It’s not much anyway. Properties are declared inside constructor method to give a distinctive line with object’s method. Any declaration and method calling are exactly the same.

done! that’s all folks, starting from day 5th, I was getting my hands dirty playing with basic react concept that available from it’s documentary and I don’t have any intend to write that out because despite of everything, I believe we could learn a framework on the fly when we had enough foundation on what it’s build upon. All you need is just a bit of ideation and constructive community, the rest would follow.

--

--

Daliska F. Royan
Daliska F. Royan