Introduction to Javascript 2020 part 1

Objects

Almost everything in javascript deals with objects, An Object has both properties and methods.
Methods are functions of an object. An object is created by
{} curly braces, also by calling Object() method.

A car is an object
A car has some properties like model and color, and methods like start and stop.
E.g


Properties of a car can be its Color, Model, Name or Engine Numbers

 Car = {}.   //Create An Object
 Car.Color = “Red”
 Car.Model = “Mercedes”
 Car.Name = “Benz”

Methods are functions of an object
Car can have a function of start() or stop()

Car.Start()
Car.Stop = Function () { //Stop Car}

Functions

Functions are block of codes that are created to perform a specified task in our program.

A function will not work until it’s called or invoked, a function entails the function keyword, a function name and can contain some arguments which are optional.

function that add two numbers

Function AddNumber (Num1 + Num2) {
     Return Num1 + Num2
 }

addNumber(4, 6)   //10

in javascript we have
self invoked functions which runs by itself without calling, We have arrow functions which simplify the way we construct our function in javascript.

let continue in the next parts. thank you

Leave a Comment

Your email address will not be published. Required fields are marked *