What is Javascript

Javascript in a technical way

technical definition from Wikipedia:

JavaScript is a high level dynamic, untyped and interpreted programming language standardized in the ECMAScript language specification, that alongside HTML and CSS is one of the three core technologies of world wide web content.

Javascript in a Practical way

Website consist of 3 layerd architecture

01- HTML

02- CSS

03- Javascript

Tools to Work

01- Code Editor

02- Browser with developer tool

Introduction to Browser Console

Javascript into HTML

Javascript Loading Methods

01- Right away loading

02- Asynchronous loading

03- Deffered Loading

How to write a good javascript

Rule#1

01- Case sensitive

02- Asynchronous loading

03- Deffered Loading

How to write a good javascript

Rule#1

01- Case sensitive

 

0
 Advanced issues found
1
var mehranBlue = "This car is blue";
console.log(mehranblue);

How to write a good javascript

Rule#2

Use camelCase

0
 Advanced issues found
1
//variable starts with lowercase letter
var mehranBlue;

//Objects and Classes Start with uppercase letters
var date = Date();

//Constants are all caps
const = CONSTANT;


How to write a good javascript

Rule#3

Whitespace 

0
 Advanced issues found
1
//With whitespace (human readable)
var dateToday = new Date();

//With no whitespace (machine readable)
var dateToday=new Date();

How to write a good javascript

Rule#4

End each statement with semicolon;

0
 Advanced issues found
1
//With Semicolon
var dateToday; 
dateToday = new Date();

//With no semicolon
var dateToday
dateToday=new Date()

How to write a good javascript

Rule#5

Use Comments

0
 Advanced issues found
1
//With Semicolon
var dateToday = new Date();

/*With no semicolon*/
var dateToday=new Date()

Variables in javascript

Simple mathematics

4 + 5 = 9

Example : Variables

// remember case sensitive

var a;
var A;
var currentTime;
var unit_4;
var $container;


Note:  You can not create a variable with number

Example : Variables

// Practical example

var a = 4;
var b = 5;
sum = a+b;
console.log (sum);


Note:  You can not create a variable with number

Syntax Example : Variables

// These three are the same

//01
var a = 4;
var b = 5;
var sum = a+b;


//02
var a,b,sum;

a = 5;
b = 4;
sum = a+b;

//03
var a = 5; var b=4; var sum = a+b;

Note:  You can not create a variable with number

DataTypes in Javascript

  • Numeric 
  • String 
  • Boolean 
  • Null
  • Undefined
  • Symbol

DataTypes in Javascript : Numeric

//Stores regular numbers and integers

var num = 1;
ver integer = 0.32659;
var negNumber = -1;
var negInteger = -3.25689

DataTypes in Javascript : String

//Stores strings of letters and symbols

var string = 'Strings are words and sentences';

//Always remember to start with a single quote

var escQuotes = "Quotes can also be \"escaped\".";

DataTypes in Javascript : Boolean

//Stores one or other of the binary pair  true/false

var theSunIsWarm = true;
var theMoonIsMadeOfCheese = false;

DataTypes in Javascript : Null

//Stores the intentional absence of the value
//variable will be empty but not undefined

var emptyInside = null;

DataTypes in Javascript : Undefinded

//Placeholder when a variable is not set

var emptyInside;

Operators : "="

//basically it looks like something is equal to something
//but in javascript "=" means, you are assigning value to the variable  

var a = 5;

Short hand Operators : "+=, -=, *=, /= "

//Short hand

var a = 5;
a = a + 5;
//or
a +=5;

Unary Operators : ++,--

//Shorthand

var a = 5;
a = a + 1;
//or

a++;

JavaScript Essentials

By Kodegems

JavaScript Essentials

  • 75