JavaScript Basics
JavaScript Basics
A code editor is the place where programmers spend most of their time.
There are two archetypes: IDE and lightweight editors. Many people feel comfortable
choosing one tool of each type.
IDE: The term IDE (Integrated Development Environment) means a powerful editor with many
features that usually operates on a “whole project.” As the name suggests, that’s not just an
editor, but a full-scale “development environment.” for example : webstorm, visual studio
code and NetBeans.
“Lightweight editors” are not as powerful as IDEs, but they’re fast, elegant and simple. For
example : Notepad++ and Sublime text
Start Coding
Comments : As time goes on, the program becomes more and more complex. It becomes
necessary to add comments which describe what happens and why
The modern mode, "use strict"
The directive looks like a string: "use strict” or ‘use strict’ When it is located on the top of the
script, then the whole script works the “modern” way.
Variables
In older scripts you may also find another keyword: var instead of let
the dollar sign '$‘and the underscore '_‘can also be used in names. They are regular symbols, just
like letters, without any special meaning.
Constants
To declare a constant (unchanging) variable, one can use const intead of let.
Variables should be named in a way that allows us to easily understand what’s inside.
Tasks
A variable in JavaScript can contain any data. A variable can at one moment be a string and
later receive a numeric value:
The number type serves both for integer and floating point numbers.
The boolean type has only two values: true and false.
The special null value does not belong to any type of those described above.
The special Undefined stands apart. It makes a type of its own, just like null
All other types are called “primitive”, because their values can contain only a single thing (be it
a string or a number or whatever).
The symbol type is used to create unique identifiers for objectsز
The typeof operator returns the type of the argument.
Tasks
You have 3
mintues
Type Conversions
You have 5
minutes
Operators
Strings Concatenations.
Operators(cont. …)
Numeric conversions.
Assignments.
Operators(cont. …)
Reminder %.
Exponentiation
Increment/decrement.
Operators(cont.)
Bitwise operators.
Tasks
What are the final values of all variables a, b, c and d after the code below?
You have 5
minutes
Interaction :alert, promote, confirm
Alert.
Confirm .
Task
You have 2
minutes
The switch statement
Write the code using if..else which would correspond to the following switch :
Functions and arrows
Task
You have
2 minutes
Replace Function Expressions with arrow functions in the code:
Operating destructing
Spread operator.
Operating destructing
Destructing.
Objects