User FAQs

If you have a question, please send it to us.

1) What is Object Orientated Programming ?
This is a style of programming that is based on objects containing methods, properties and fields arranged in a hierarchy.
This type of programming is based around four key features:
Polymorphism - Create routines that can operate on objects of different types. This is handled by late binding and multiple interfaces.
Encapsulation - Hide parts of the implementation and hide complexity. This can be achieved using a Module Pattern.
Inheritance (Interface) - (Public Inheritance) Define methods (without implementation) that must be declared in a derived class.
Inheritance (Implementation) - (Private Inheritance) Inherit method implementation from a base class.

2) Is JavaScript an Object Orientated programming language ?
Yes although it is not a class based object orientated language like C#
Polymorphism - Yes because it is not strictly typed
Encapsulation - Yes. Using modules (IIFE)
Inheritance (Interface) -
Inheritance (Implementation) -
Inheritance (Implementation) - Can be achieved using prototyping but is at the expense of encapsulation

3) Are semicolons required at the end of statements ?
Certain statements must be terminated with semicolons.
Semicolons can be omitted in certain situations and when omitted they will be inserted for you automatically.
If you do not include them you will be relying on a process called Automatic Semicolon Insertion (ASI).
There are a number of cases when the ASI will insert one in the wrong place.

a = b + c 
(d + e).print()

This translates to "a = b + c(d + e).print" which is different.

   var1 = 'Mon'

This translates to "return; { var1 = 'Mon' }" which is different.

4) What is the difference between 'var', 'let' and 'const'?
A variable declared with var outside a function has global scope.
A variable declared with var inside a function has function scope. This will take precedence over the same variable declared outside the function.
The scope of var can be global or function (not block).
The scope of let can be global, function or block.
The scope of const can be global, function or block and cannot be reused or reassigned later.
A variable declared with let at the global scope will not be added to the global window object.

var myVar = 'Tuesday';  
function fun_One() {
   var myVar = 'Wednesday';
   console.log( myVar );
console.log( myVar ); // Tuesday
fun_One(); // Wednesday

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext