Singleton objects in JavaScript
🪼
Show & Tell
2025 on Tumblr: Trends That Defined the Year
cherry valley forever
almost home
Cosimo Galluzzi
trying on a metaphor
No title available
todays bird

★
Today's Document

bliss lane
Misplaced Lens Cap
The Stonewall Inn
Lint Roller? I Barely Know Her
Monterey Bay Aquarium
d e v o n
Cosmic Funnies

Andulka
Claire Keane
seen from Bangladesh

seen from United States
seen from United States
seen from United States
seen from United Kingdom
seen from United States

seen from United States
seen from United States
seen from United States
seen from United States

seen from United States
seen from T1
seen from United States
seen from United States
seen from Netherlands
seen from Malaysia
seen from Canada
seen from Argentina

seen from Argentina

seen from Malaysia
@ng-learner
Singleton objects in JavaScript
what the f**k is apply, call and bind?
use of ‘use strict’?
this & prototype functions
Objects in JavaScript
As we all know,objects are instance of a class.
2 ways to create an object in JavaScript It's important to note that there are no classes(except in ES6) in JavaScript. Functions can be used to somewhat simulate classes, but in general JavaScript is a class-less language. Everything is an object. And when it comes to inheritance, objects inherit from objects, not classes from classes as in the classical languages.
Using Functions
Using Object literals
Classes in JavaScript
Defines the object's characteristics. A class is a template definition of an object's properties and methods.
JavaScript is a prototype-based language and contains no class statement, such as is found in C++ or Java (Classes are introduced in ES6).
In JavaScript , functions are classes.
function myClass() { var privateVariable; var privateMethod = function(){ /* function definition*/ }
function anotherPrivateMethod(){ /* function definition*/ }
this.publicVariable; this.publicFunction = function(){ /* function definition*/ } }
Namespace in JavaScript
A container which lets developers bundle all functionality under a unique, application-specific name. Creating a namespace in JavaScript is simple, create one global object, and all variables, methods, and functions become properties of that object.
Use of namespaces also reduces the chance of name conflicts in an application,since each application's objects are properties of an application-defined global object.
// global namespace var MYAPP = MYAPP || {};
//creating Sub namespace MYAPP.event = {};
Naming namespace,you'll capitalize the first letter. If your app requires use of global scope, it's good practice to use a namespace like this to prevent name conflicts (just as jQuery uses $ as a namespace in order to access all the methods and properties of its API).
var myApplication = { getInfo:function(){ /* function definition */ }, models : {
}, views : { pages : {} }, collections : { } };
For get to know more about Namespace patterns click here
JavaScript is Object Oriented?
Object-oriented to the core, JavaScript features powerful, flexible capabilities
Terminologies
Namespace
Class
Object
Property
Method
Constructor
Inheritance
Encapsulation
Abstraction
Polymorphism
So what is dynamic typed?
Whether or not a language is dynamic typically refers to the type of binding the compiler does: static or late binding.
Static binding simply means that the method is bound at compile time.
Dynamic languages are the opposite. They do their work at runtime. They do little or no checking for the existence of methods at compile time but instead do it all at runtime.
What is JavaScript ?
JavaScript is an object-oriented dynamic language with types and operators, standard built-in objects, and methods.
Remember, before you can be great, you’ve got to be good. Before you can be good,you’ve got to be bad. But before you can even be bad, you’ve got to try.
Art Williams