JavaScript Quiz #12

Assume that we have the following short JavaScript code:

<script>
    var number = 50;
    var obj = {
        number: 60,
        getNum: function () {
	    var number = 70;
	    return this.number;
	}
    }; 

    alert(obj.getNum());
    alert(obj.getNum.call());
    alert(obj.getNum.call({number:20}));
</script> 

Will this code succeed or fail? and if it succeeds, what is the output of the alerts?

Read the complete answer

JavaScript Quiz #7

Assume that we have the following short JavaScript code:

<script>
    var result = typeof("Hello" instanceof String);
    alert(result); //What is the output of the alert? 
	
    result = typeof typeof("Hello" instanceof String);
    alert(result); //What is the output of the alert? 
	
    result = typeof typeof typeof("Hello" instanceof String);
    alert(result); //What is the output of the alert? 	
</script>

What is the output of each alert?

Know the complete answer