Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 6, 2020 05:55 pm GMT

How I started JavaScript

Hello Enthusiasts of the Computer Science World!

What is JavaScript?

JavaScript can be the biggest step you can take in your developer career, however when first starting JavaScript it was the hardest thing to grasp, I remember being confused and frustrated along the way. Although this is true I'm here to tell you this is the right option and you need to stick through it, just like learning any language with enough time and practice you will become fluent. Lets stay strong and stay determined.

JavaScript was created in 1995 by the Netscape web browser, it was a way to add actions to websites, JavaScript is like the verb of a website, call to action. In 1995 it was a way to beat the competition, JavaScript became the standard also called ECMAScript when it was first introduced. Every website nowadays uses an excessive amount of JavaScript for example, adding something to your cart on Amazon, signing in to your account in any website, liking a post on DEV, virtual reality, robotics, this is all made possible through JavaScript. This one skill will take you very far into your career and opens up a lot of possibilities, however take things step by step and think simply that JavaScript is just a file that you can write instructions to a computer telling it to do as you desire and code.

Principles of JavaScript

First lets talk about JavaScript types, there a seven types or primitive values , you can open and try these commands in any console, example go to any website, right click, inspect element, open console:

JavaScript TypesExamples
Number2+2 = 4
String"Hello" + "World"
BooleanRepresents and Gives either True or False
UndefinedUsed when nothing is assigned to a variable
Nullthe value represents the intentional absence of any object value
Symbolreturns a value of type symbol, has static properties that expose several members of built-in objects
Objectobjects are containers for named values called properties or methods they follow name:value pairs

Secondly we have JavaScript Comparisons, these come in very useful with Booleans and they are very simple to understand as they are literally just comparing any type to another:

JavaScript ComparisonsExamples
!==3!==3 the ! basically means not, therefore 3 doesn't not equal three would return false
===3=3 would not work therefore always 3===3
>=3>=3 three is greater than or equal to three would return true
<=3<=3 three is less than or equal to three would return true
>3>3 would return false
<3<3 would return false

Next you would look into JavaScript Variables now this is when JavaScript starts to get fun, this is how a program starts to remember things. A variable stores something and we can access that content through it for example:

var post = "This is my blog about starting JavaScript"// Type in post now in console post"This is my blog about starting JavaScript"
Enter fullscreen mode Exit fullscreen mode

These variables are super important and can hold any type of content here are the different ways of calling them:

JavaScript VariablesExamples
varvar= "hello" the first and basic way to declare a variable
letlet= "hello" the new and improved version to declare a variable
constconst="hello" unlike the other two this variable you cannot modify its not interchangeable like others, hence its constant

Fourth on the list is JavaScript Conditionals, these conditionals are to control and make decisions that you have written in your code, there are a few:

JavaScript ConditionalsExamples
ifbasically if would say if this is right then right true
elseif its anything other than the if or later on else if then finally run this
else ifthe computer would run after the if the else to see if that is correct to run that

For example:

var name = "Billy"if (name === "Billy") {   alert("hi Billy!");}
Enter fullscreen mode Exit fullscreen mode

P.S. All alert() does is make a pop up for the user to display that information that it is correct so the computer will return a pop up saying HI Billy! when running in console.

Afterwards there are three logical operators in JavaScript. Although they are called logical, they can be applied to values of any type, not only boolean. Their result can also be of any type. Let's take a look:

JavaScript Logical OperatorsExamples
&&The AND operator is represented with two ampersands &&. AND returns true if both operands are truthy and false
"//"OR is meant to manipulate Boolean values only. If any of its arguments are true, it returns true, otherwise it returns false
!The Boolean NOT operator is represented with an exclamation sign ! Converts the operand to Boolean type: true/false. Returns the inverse value.

Finally we have JavaScript Functions these are the most important values you will learn in JavaScript to execute everything, they are pieces of code that perform actions, without them JavaScript wouldn't really do anything these actions can preform one or multiple. All functions are followed by () these call the function and then are {} these are the arguments, what's given to functions. These are different types of function:

JavaScript FunctionsExamples
var a = function name() {}function declaration
function name () {}anonymous function
returnthis returns a value in a function, it's important to have this to make sure the function acts the way we want it to
console.log()the Console method log() outputs a message to the web console

Function Explanation Diagram
Alt Text

Hopefully now you have a better understanding of JavaScript and realize that it goes a lot further than just these principles and fundamentals which you should practice and master to continue your path smoothly. I hope it wasn't as bad as you thought because at first I really did, and if you're still not there continue practicing, make fun simple projects I believe those maximize your understanding and comprehension in a not so frustrating way. Thank you for reading and remember to keep coding!


Original Link: https://dev.to/javiercunat/how-i-started-javascript-39kf

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To