Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
vartruck={start:function(){console.log("Truck in Started!");}}varbus={start:function(){console.log("Bus is Started!");}}
Start method is scoped inside it's object (context).
truck.start();// Truck in Started!bus.start();// Bus is Started!
Namespace usage protects and isolates the code from other applications.
You can use multiple functions with the same name, then distinguish them by utilizing the JavaScript namespace like in the example above.
It becomes easier to recognize the variables and functions from where they are defined.
It's not the only way to reach that. Setting private functions for example, won't clash against other private ones so they are contextualized separatelly be they with the same name or not.
The difference with the namespaces are that you mark a data structure (Object) property as the method so you always call it through the instantiation object name plus the method name.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Namespaces are a paradigm and not a "feature".
Start method is scoped inside it's object (context).
It's not the only way to reach that. Setting private functions for example, won't clash against other private ones so they are contextualized separatelly be they with the same name or not.
The difference with the namespaces are that you mark a data structure (Object) property as the method so you always call it through the instantiation object name plus the method name.