JavaScript Fundamental


Javascript is a programming language like Python, C++ and others. This language is widely used for web development. So we will encounter javascript when browsing the internet with a browser.


Where can Javascript be executed?

1. Browsers
Every browser (Firefox, Chrome, Safari and others) has an engine that can execute Javascript code, this engine acts as a translator as well as a liaison between Javascript and our computer, so in general, this engine which forwards our commands and notifies computer what to do. 
Some famous Javascript engines:
  • V8 Engine → Chrome
  • Spider Monkey → Firefox
2. Node.JS
Node is another place where Javascript can be executed, more specifically, we run Javascript directly on our computer. If in the browser, we still have an intermediary to run it, the browser.


JavaScript Code Structure

1. Statements
Like a statement in language, a statement serves to state a command or just give information to the computer. 

For example, we tell the computer to turn off, by pressing the shutdown button on our laptop. When we press the shutdown button, the computer will run a command that has been wrapped in a code, to tell the command, we must add a statement in the code.

Open Browser then click F12 in keyboard to show console because JavaScript can be executed in console.


console.log here is called as Statement. Statement is not only console.log. This is only a sample.

2. Semicolon
Semicolon is used to separate the statements from one another. However, semicolons are not actually required in Javascript, just to distinguish between statements. For example:
  • console.log("Hello World");
  • console.log("I learn about JavaScript");

3. Comments
Comments are strings of code that are ignored by the engine running them. But comments are important, to let other developers know or maybe remind ourselves of the code we wrote. This type of comment starts with two slashes '//'.



JavaScript Variable


let message in picture above is called as Variable.


JavaScript Data Types
The following data types exist in JavaScript:

1. String
The data type that stores the value is a character, starting from letters, numbers, symbols and so on, where the value will be surrounded by quotation marks. For example:
  • "This is String 12345 !@#$%^"
  • 'This is String 12345 !@#$%^'
  • `This is String 12345 !@#$%^`

2. Number
The data type that stores the value is number without quotation marks. For example: 12345

3. Boolean
The data type that stores the value is true or false. For example:


4. null
A data type whose value is empty or null

5. undefined
The data type is undefined, meaning that there is no value source in the data. This value usually appears when we define a variable but we don't put a value into it at all.

6. Object
Object is a data type that stores a collection of other data types. For example, an object can have a string, number, boolean all at once. Since an object is a collection of data, there must be a key to call one of the data collections in the object. The key we usually call the key, and the value we usually call the value, and the key and value pair we call the property. For example:
  • let SampleObject = { name: "Sabrina", age: 25, gender: "female", married: false }
name, age, gender and married are called key.


JavaScript Operators
JavaScript Operators consist of many operators such as Arithmetic operators, Assignment operators, String operators, Comparison operators, Logical operators, Type operators, and Bitwise operators. Detail descriptions about all of these operators can be read from here:

Comments

Popular posts from this blog

ReactJS: Protected Routes Implementation in ReactJS

How to Inspect Problems in Your ReactJS Codes