JavaScript is probably one of the most commonly used programming languages ββnowadays. It has a wide range of applications in almost all technologies
π§΅ππ»
If you're planning to start with coding then JavaScript would not be a bad choice. In fact, it is the best choice. Why?
1. You can use it everywhere 2. A lot of jobs opportunities 3. Easy to learn
Lets talk about the use cases of JavaScript in bit detail
Web development is probably the largest field in IT industry. People all around the globe using web services in some context which makes this field even vast and eventually opens doors for beginners....
JavaScript gives you a job security. That's why every beginner can and should start their coding journey with JavaScript.
π JavaScript is a single threaded language
In simple terms we can say that JavaScript executes code in order and must finish executing a piece code before moving onto the next one.
Does this make JavaScript a slow language? No ππ»
Although JavaScript is a single threaded language but we have a concept called event loop.
Using a few smart data structures we can achieve the multi threaded functionality in JavaScript. Let's talk more about it ππ»
π Event loop
Call stack - It keeps all the operations in order which has to be executed. After successful execution, it is popped out.
Event Queue - It is responsible for sending new functions to the track for processing.
Event queue is a queue data structure which sends all the operation into call stack in order.
One key point to note here is that if an async function is called, it is sent to web API. For example setTimeout method.
Whenever setTimeout comes in stack, it is sent to web API which waits for the specified time to send this operation back to event queue.
Hence it is a cycle like this ππ»
The another interesting part about is JavaScript is that you can start with it right away. Let me tell you how!?
You can run JavaScript on the client side and on the server side as well. Which means you can run JavaScript code right in your browser.
Follow this quick steps to get a taste of JavaScript
- Open your browser
- Right click anywhere
- Inspect
- A window will come
- From the top navigation bar, go to console
Here you can write JavaScript code
A typical roadmap of JavaScript. Starting with the basic topics
1. Print statement 2. Data types and variables 3. Basic operators 4. Logical operators 5. Comparisons 6. Loops and statements 7. alert() 8. prompt() 9. Arrays 10. Objects
11. Functions 12. Arrow function 13. Array methods 14. Hoisting 15. Closures 16. Callbacks 17. Promises 18. Async & Await 19. Currying 20. And other ES6 feature
Alright, although JavaScript has wide range of application but it is mostly used in web technologies. So let's talk a bit about JavaScript in terms of web development ππ»
Start with JavaScript Variables
Variable are nothing but containers for storing data values. You will use them almost 100% in your JavaScript code.
There are three ways to declare a variable using var, let and const keyword
JavaScript is used to add some functionality in website. So that user can interact with the website. For that we have two basic methods:
An alert box is often used to popup some message whereas prompt is used for taking input from user
JavaScript - HTML DOM methods
You might know that JavaScript is for adding behaviour in your webpage. For that you need to catch the HTML element so that you can change things accordingly
HTML DOM methods are actions
HTML DOM properties are values that you can set
Using HTML DOM you can
- Catch element in JavaScript file
- Change whatever you want
- Add or delete element
π Events
You can handle various events using JavaScript. An event can be defined as something the browser does, or something a user does.
For example, click is a event that user does, whereas onload is a event when user enters the page
An example of typical click event
The onclick attribute fires on a mouse click on the element.
You can check my handmade cheat sheets and notes of JavaScript in this thread
Structuring your website is essential as it provides better navigation and visualization of the content available on the site. Let's talk a little more about it and learn how we can create a proper layout
π§΅ππ»
Web layout aims for presenting imformation in a logical manner and to make the important elements stand out.
A well designed layout can catch more traffic on your website and make your content easy to understand
π Design vs Layout?
Web layout is closely related to designing part. But we can say that web designing is much more than the layout only. It covers images, text, color scheme, typography and layout
On the other hand, Layout is all about arrangement of element on the webpage
Let's decode in this thread how we can create Ferb using few simple CSS steps. Let's go
π§΅ππ»
STEP 1: Create a Face of rectangular shape
- Create a rectangle and rotate it a little bit
- Give it a solid border without border-bottom
- Position it
STEP 2: Create Lips
- Make a small square
- Add bottom and left border
- Skew it so that it seems like a lip
- Add little bit of bottom-left radius to give it a more realistic look