JavaScript Presentation
JavaScript Presentation
PRESENTATION
ON
JavaScript
Aadityanath Maurya(2001200100001)
Introduction
JavaScript syntax
Data Types And Variables
Conditional Statements
Operators
Introduction
Writing our first code
The very first exercise every programmer goes through is the printing Hello world! message to the console.
Let’s do it with JavaScript: you should use the console.log() statement like in the example:
console.log('Hello world!');
You can see from the above example that we displayed a message My age is: 23 with a
value of the variable age.
why should we use the variables
Variable can store any value, so you can assign it and use it as many times as you need. For example, if you
need value 23 ten times, you can create and use a variable age with this value. Then, if you need to change
your age, you`ll do it once by changing the variable, not changing all 10 occurrences of your value.
Compare two next examples:
let age = 23
console.log('My age is: ', age)
console.log('My age is still: ', age)
console.log('Now my age is: ', age)
If you need to change your age, in the first example, you'll have to do it three times, and in the second, you'll
only change the value of age variable, and then all other occurrences will be changed automatically. That's why
we should use the variables.
JavaScript Syntax
JavaScript Syntax
JavaScript Syntax is a set of rules which defines that our JavaScript program has the correct structure
or not.
In the program we usually perform the following things:
Declaration of variables
Assignment of values.
Computation of values by using operators
//declaration of variables
const firstNumber = 100;
const secondNumber = 5;
const thirdNumber = firstNumber + secondNumber;
console.log(thirdNumber);
JavaScript Values:
A value is the representation of some entity that can be executed by a program.
In JavaScript there are two types of values:
Fixed values are known as literals.
Variables values are known as variables.
JavaScript Variables
In JavaScript, variables are used to store data. JavaScript variables are “named storage” for data. We can access the
value of the variable by using variable name. We can use the variables to store different kinds of data like numbers,
text, Boolean, etc.
JavaScript Variables syntax:
A variable in JavaScript has a name, a value, and a memory address.
JavaScript operators
We use operators to performing some actions on the operands. Operands can be variables, numeric literals, or string
literals.
// (bitwise operator)
const value = 5 | 1;
console.log(value);
// (logical operator)
const isRaining = true;
console.log(isRaining);
//(assignment opearator)
const number = 5;
console.log(number);
// (relational operator)
const isLess = 45 == 10;
console.log(isLess);
Description of the above code:
Identifiers in JavaScript
An identifier is simply a name. Identifiers are names given to entities like variables, arrays,
functions, classes, etc. In programming, we often store some values in some variables for later use,
and for this, we give some names to variables.
NOTE:
Identifire names must start with a number, an underscore(_), or with a dollar sign($).
Identifire names cannot start with a number.
JavaScript is case sensitive i.e. ‘Greeting’ is different from ‘greeting’.
Keywords cannot be used as identifire names.
//valid identifier name
let greeting="hello-world";
console.log(greeting);
let 1number=10;
Naming Identifires:
Though you can name identifiers in any way you want, it’s a good practice to give a descriptive identifier
name.
Names should be logical.
If you are using an identifier for a variable to store the number of students, it is better to use students,
numberOfStudents, or number_of_students rather than x or n.
In both cases, the output is the same but the second and the third identifiers are more meaningful.
Reserved Keywords In JavaScript
JavaScript uses many identifiers as the keywords for language to give power to the language itself. We should
avoid using keywords as identifiers for our programs.
Those keywords are for a specific purpose and perform a specific task that empowers the language itself.
Following are some legal ordinary JavaScript words but they are reserved in strict mode:
implements, let, private, public, yield, interface, package, protected, and static.
Note: This strict context forbids particular actions from being taken and sends more exceptions. The statement
“use strict”; guide the browser to use the Strict mode, which is a reduced and safer feature set of JavaScript
ECMAScript 5 reserved keywords:
Fig.-1
Naming Convention in JavaScript. Case Styles
Naming conventions propose logic when it comes to naming identifiers. No one imposes these naming conventions
as rules, however, they are generally considered in the JavaScript community.
UPPERCASE: In the upper case all the letters are capital, for example, HOURS, and PI. Constants are usually
written in upper-case.
lowercase: In lower case all the letters are small, for example, name, and age. Variable names having only one
word are usually written in lower-case.
camelCase: Writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital
letter, for example, variableA, and studentsCount. Functions are usually written in camelCase notation.
PascalCase: Writing phrases such that each word in the phrase begins with a capital letter, for example,
HumanBeing, and StudentsCount. Classes are usually written in PascalCase
//lowercase
let name = 'bob william';
console.log(name);
//uppercase
let NAME = 'PAUL ANTHONY';
console.log(NAME);
//camelcase
let fullPrice = 1000;
console.log(fullPrice);
//pascal notation
let SoftwareDeveloper = true;
console.log(SoftwareDeveloper);
CONT.........
Conclusion
It was a wonderful and learning experience for me while learning this new programming
language.It gave me the basic understanding of ‘JavaScript’ programming language. The
joy of work and thrill involved while tackling the problem and challenges gave me the feel
of a developer.
I enjoyed each and every bit of work I had put into this.
Internship Organization
https://www.learnvern.com/
https://codefinity.io/about/
Thank You.....