What is Programming?
What is a Code Editor and which one is the best to use?
In my opinion, a code editor is a supporting tool for every programming languages where we can write our codes for
There are different code editors but we(programmers) use them as per our taste.
I mean to say that someone finds ‘Sublime Text’ so easy to use whereas some say ‘Visual Studio Code’
is the best though the purpose of using text editor is the same.
If we are beginners, I suggest
Visual Studio Code because I find some extra features than other editors
but it depends upon your preference.
What does Developer Tool mean?
The developer tool is a set of tools that is available in a browser where we can test our codes, see errors, and also examine variables.
The example of a developer tool is
How to attach files, external files, inside <script> tag?
Script files are attached to HTML with the src attribute:
1 <script src="file.js"></script>
External Script files are attached to HTML with the src attribute:
1 <script src="/path/to/script.js"></script>
We can give a full URL as well. For instance:
1 <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js"></script>
A single <script> tag can’t have both the src attribute and code inside.
1 2 3 <script src="file.js"> alert(1); // the content is ignored, because src is set </script>
How to put comments in Java Script?
Comments are ignored by the engine. If we want to make clear about our codes to users we do comments.
We can comment in two ways. If we have to comment in one line we give two forward slashes i.e // whereas If we have
to give comments in multiline we start with a forward slash
and an asterisk
/* and end with an asterisk and a forward slash
1 2 3 4 5 //This is single line comment.// /* This is multiline comment. This is second line. */
How to write code?
Codes are written in many statements separating with semicolons.
1 2 3 4 5 /* Two alerts Hello and world. Firstly, computer will alert Hello and then will alert world.*/ alert('Hello'); alert('World');
Usually, statements are written on separate lines to make the code more readable:
1 2 3 4 5 // In Js semicolon can be omitted but I want always to insert semicolon at line breaks. alert('Hello'); alert('World');
Is “use strict” that important you should care about?
at the top of a script file. Modern js supports advanced language Structure,
that enables use strict automatically.
What is a Variable?
Variable is a pointer where we store data and assign value to it. We declare Variable to store data by using the var, let, or const keywords. Always declare a let for a variable declaration to run your codes at the local scope. let is a modern way of declaring variables whereas var is an old way. Variable name must contain only numbers, only letters, or the symbols $ and _. Variable naming must be meaningful. In the above diagram, the variable is pointing to data 1 and data2.
1 2 3 4 5 6 7 let message; //declaring a variable with the name "message" message = 'Hello'; // store the alert(message); // shows the variable content
We can also declare multiple variables in one line as in the example below:
1 2 3 let user = 'John', age = 25, message = 'Hello';
What is a Constant?
Constant is also like a variable but the difference is, constant cannot be assigned with another value once defined.
This is why the same constant name cannot point to
Data 2 once it’s pointed to
Some constants are named using capital letters and underscore to make a difference.
To declare a constant (unchanging) variable, use
const instead of
1 2 3 4 5 6 7 8 9 10 const myBirthday = '19.03.1980'; //declaring constant variable myBirthday = '01.02.2000'; // error, can't reassign the constant value! const COLOR_RED = "#F00"; //uppercase constant let color = COLOR_RED; alert(color); //#F00 will be the output
What are Data-Types?
In simple concept, Data types are
let n = 123;
Stringmeans quotes: double quotes, single quotes, backticks;
let name = "John";
Booleanmeans two values: true and false;
let isGreater = 3 > 1;result comes true
Nullrepresents “empty” or “unknown value”
let age = null;means age is unknown.
Undefinedis alike null but its not mean empty. It means variable if declared but not assigned, then its value is
let age;shows undefined on alert.
Bigintmeans big integer value. Example
10n. The “n” at the end means it’s a BigInt.
const bigInt = 1234567892345567788n;
Alert shows a message.
Confirm shows a message and waits for the user to press “OK” or “Cancel”. It returns
true for OK and
false for Cancel.
You might also like