Learning Step by Step - 222
Learning Step by Step - 222
Create Environments: How to create file and folder for coding etc;
a. Create file and then open with code.
b. Create New Terminal on VS. Code and set it in Command Prompt.
c. Type, tsc –init to generate tsconfig.json file.
d. Type npm init -y to generate package.json file
e. Type npm i @types/node -D to install package-lock.json file and
node_modules.
f. Create .gitignore file and type node_modules in it.
g. Create app.ts file and type any code in it.
h. Type tsc app.js to compile transcript code (TS CODE) into Java Script (JS
CODE).
j. Type node app.js to execute code.
k. Create file from Github and run it to VS Code
l. Published file on NPM
3 Type of Variable:
(a). var, (b). let and (c). const)
a. Var: Declare and Re-assignable
b. Let: Declare and Re-assignable (changeable)
c. Const: Declare but Not Re-assignable (not-changeable)
Modules
In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or
export is considered a module. Conversely, a file without any top-level import or export
declarations is treated as a script whose contents are available in the global scope (and
therefore to modules as well).
What is ECMAScript 2015?
ES6 or the ECMAScript 2015 is the 6th and major edition of the ECMAScript language
specification standard. It defines the standard for the implementation of JavaScript and
it has become much more popular than the previous edition ES5. ES6 comes with
significant changes to the JavaScript language.
Data: Data types in JavaScript define the data type that a variable can store.
JavaScript includes primitive and non-primitive data types. The primitive data types in
JavaScript include string, number, boolean, undefined, null, and symbol. The non-
primitive data type includes the object. Two type of Data:
String Array
Number Object
Boolean Function
Undefined
Null
Symbol
Primitive Data
String: The String object is used to represent and manipulate a sequence of
characters.
Boolean: Very often, in programming, you will need a data type that can
only have one of two values, like
YES / NO
ON / OFF
TRUE / FALSE
For this, JavaScript has a Boolean data type. It can only take the
values true or false.
Non-Primitive Data
Array: If you have a list of items (a list of car names, for example),
storing the cars in single variables could look like this:
let car1= "Saab";
let car2= "Volvo";
let car3 = "BMW";
However, what if you want to loop through the cars and find a specific
one? And what if you had not 3 cars, but 300?, However, what if you want
to loop through the cars and find a specific one? And what if you had not 3
cars, but 300?, The solution is an array!. An array can hold many values
under a single name, and you can access the values by referring to an
index number.
A car has properties like weight and color, and methods like start and
stop:
All cars have the same properties, but the property values differ from
car to car.
All cars have the same methods, but the methods are performed at
different times.
Operators: Operators are the symbols between values that allow different
operations like addition, subtraction, multiplication, and more. JavaScript has
dozens of operators, so let's focus on the ones you're likely to see most often.
b. Non-Primitive Data
Dated: 11 March 2024
Variables:
a. Let :
b. Cost
c. Var: is a key word for (reassign and re declare
ISFAYAN
03059487339
DATA TYPE
Two type of Data:
a. Primitive Data
b. Non-Primitive Data
Variable Naming:
Don’t Does
You can not use reserved names (words) Use camel case variable names
Can not begin with number eg; let myName = “Ali”
Can not use space in a name let myMarks = “95”
No other symbol other then ‘$’ or ‘_’ with number in name:
eg; let position10 = “Shahid”;
with symbol
eg; let position_10 = “Noman”
let total$ = 100
Const: can neither be re-declared and nor updated. It is block scope variable.
({
1. name: "pin", PIN
2. message: "Enter your pin number?",
3. type: "number",
});
if (pinAnswer.pin === myPin)
console.log("Correct pin code!");
({
name: "operation",
type: "list",
});
([
{name: "amount",
AMOUNT ANSWER
message: "Enter your amount?",
type: "number",
},
]);
myBalance -= amountAns.amount;
console.log("Insufficient balance");
name:"cashAmount",
type:"list",
});
}
}
else {