101. What is inside the global object?
When the global object is created, it is given some initial properties. These properties include:
global functions such as parseFloat(), and eval()
global properties such as NaN and Inifinity
global objects such as Intl and Math
//the code below uses an arbitrary variable name – globalObj –
//to reference the global object
var globalObj = this;
103. Is the Window object a global object also?
Provide an example of how a wrapper object would work.
var strng = “ProgrammerInterview is Great!”;
//the letter variable will hold a “P”:
var letter = strng.charAt(0);
In the code above, the strng variable is set to a string – “ProgrammerInterview is Great!”. Then, the first letter of that string is retrieved and stored in the letter variable – this would be the letter “P”.
The wrapper object will inherit all of the string methods, like charAt. And as soon as the property – in this case the charAt method – is correctly used, then the object that has just been created is thrown away. So, another word for the wrapper object is a “transient object”, because transient means something that appears just temporarily and then disappears.
Finally, let’s consider one last example:
var someString = “hello”;
someString.size = 5;
// s will be undefined:
var s = someString.size;
In the code above, someString is obviously a string set to “hello”. We then create a temporary String object and set a property named “size” on the someString string. The object, however, is then thrown away. So, when we try to access the size property in the third line, the variable “s” will actually be undefined, because that property does not exist since the String object created was only temporary.
The whole point of the code above is to demonstrate the fact that when you try to set the value of a property on a string then it simply won’t work, because it’s just set on temporary object. But, when you try to read the value of a property (like we did in our earlier example using charAt), then it works just fine. This is because of the fact that the string will act like an object temporarily and allow you to use a method – well, it’s actually a wrapper object, but hopefully you understand the difference now!
106. What is ECMAScript?
108. Do other languages use the ECMAScript standard?
109. What is the latest version of ECMAScript?
ECMAScript version 5 was finished in December 2009, the latest versions of all major browsers (Chrome, Safari, Firefox, and IE) have implemented version 5. Version 5.1 was finished in June, 2011.
110. Why is it called ECMAScript?