Local based variable declaration before usage is available in most
languages like javascript, python, and many more. php has this, but it's
only available while working/dealing with oop related.
Hello Oladoyinbo,
I'll contribute an observation, correct me if I'm wrong.
In Python or Javascript it is not possible to declare types, as they are dynamic languages, similar to PHP.
What you can do in Python is write type annotations, but it doesn't change its type at run time.
myVar: int = 5;
print(myVar); # The output is 5
myVar = 'Marcos';
print(myVar); # The way out is Marcos
myVar = True;
print(myVar); # The output is True
As for Javascript, it doesn't even have type annotations, you need to use
JSDoc to document, or use
Typescript to use types.
Hug.
---
Marcos Marcolin
Software Engineer | PHP
www.marcosmarcolin.com.br