What is a VAR?
VAR can be used for anything everywhere
var keyword can be used everywhere. You can put in all kinds of information. Strings, Int, Object, Array, Function. That is great, well most of the time!
Variables can be used for everything, but also everywhere. You can access a
var from inside a function, object, if-else statement, really everywhere! That maybe sounds cool, but can have a big effect on the performance of a website or web-application.
var is or can be globally scoped. Cool to access everything from inside anything! But is that good? With the coming of ES6 there are a few alternatives ahead. There are called
const. They have different behavior than
var. But let’s talk about that later.
Can be changed later
A variable can be defined with a string, later on, reassigned to an integer and later it could be a function. That is a power but also a weakness.
var globalVariable; globalVariable = 'I Love Pizza!'; console.log(globalVariable); // Will be 'I Love Pizza!'