In JavaScript almost everything is object or act like object. Most values (excluding primitive values) involve object being created or instantiated from constructor function. An object returned from the constructor is called an instance. JavaScript uses native constructor to build everything.
JavaScript has nine native constructors to achieve everything in JavaScript programming language. For example functions are objects created from Function() constructor. String(), Boolean() and Number() constructors are not only construct objects but also provide primitive value for string, Boolean, and number.
- String()
- Boolean()
- Number()
- Object()
- Function()
- Array()
- RegExp()
- Error()
- Date()
To remember these 9 native constructors I have created one acronym "SBN OF A RED". This acronym is easy to learn and also in relevant groups.
To create a number variable in JavaScript there are 2 ways:
- var iMyNumberPrimitive = 9;
- var iMyNumberObject = new Number(9);
Same way we can create other type of variables also. It is good practice to use simple primitive variable declaration always if we want normal variables operations, because JavaScript create complex object when you use constructor and will have many other properties associated with variable.
You also like to know about:
- Do you know what happens when you hit url www.goolge.com?
- Know about Debouncing & Throttling
- AngularJS advanced trick and techniques
- Restrict input to allow only required value (jQuery plugin for input type validation)
- Spread operator or Rest parameter or Ellipsis in JavaScript
- Why call and apply two methods available in JavaScript
- Automatic Form Input Validation for complete site
- Number of ways you can create function in JavaScript +what are they called
- JavaScript Native objects
- How to Create private function in JavaScript
- functions as first class object in JavaScript
- Object Oriented concept in JavaScript
- Advanced JavaScript questions
- One good way to declare Global Variables in JavaScript
- how to align elements in a row with equal space around
- Closures in JavaScript
- AJAX call in AngularJS for cross domain service using JSONP
- Cross Site Scripting in WCF Web Service. How to use AJAX in JavaScript to Get/Consume JSON from WCF in C#
- How to add AngularJS in rails application
- Git configuration all about
- Pass XML file in stored procedure as a input parameter from C#
- XML Parser in SQL Server (T-SQL), How to parse XML in SQL
- Wish your friend with your own words and love
- Create Message in Hindi by typing in Hinglish
- Convert Multiline Text Into Single Line for HTML page