HOTSPOT
You troubleshoot a webpage that includes the following code segment:
You need to evaluate the value of the variable named customer.name.
For each statement in the table, select Yes if the code segment above causes the variable to evaluate
as described. Select No if it does not. Make only one selection in each column.
Technically, null should be Yes as well:
http://jsfiddle.net/yrgq4zdb/
In your fiddle uses not strong type comparsion. Use strong comparsion (=== instead of ==) and you’ll recieve undefined – true.
alert() will show undefined.
only with assertions undefined will also be true:
http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3
I don’t understand this question. Rediculous question.
ejercicio
var customer = function () {
var name = “Contoso”;
return {
getName: function () {
return name;
},
setName: function (newName) {
name = newName;
}
};
}();
document.getElementById(“resultado”).innerHTML =
” ‘Contoso’ = ” + (customer.name === “Contoso”) + “” +
” undefined = ” + (customer.name === undefined) + “” +
” null = ” + (customer.name === null) + “” +
” false = ” + (customer.name === false);
resultado:
‘Contoso’ = false
undefined = true
null = false
false = false
es correcta la pregunta
the return part makes sure that the “name” property is private and not accessible using Customer.name.
It is only possible to get the name property by using customer.getName()
as such Customer.name is undefined.
I can’t seem to find any documentation explaining why this should be true.
Infact, as states in this link (http://www.crockford.com/javascript/private.html):
* Private members are made by the constructor.
* Ordinary vars and parameters of the constructor becomes the private members.
*
* function Container(param) {
* this.member = param;
* var secret = 3;
* var that = this;
* }
*
* This constructor makes three private instance variables: param, secret, and that
and being the variable ‘name’ defined inside the function as ‘var name’ this should be the reason why it’s private.
Can you give some reference for your assumption?
Thanks for your comments.Especially J you defined very well.thanks